Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit ComboBox Content Stretching...
1 replies. Latest Post by BrianGenisio on July 2, 2009.
(0)
BrianGen...
Member
26 points
23 Posts
07-02-2009 11:01 AM |
I am trying to get the content of my ComboBox to stretch to the size of the DropDown. I can't, for the life of me, solve this. What am I missing?
<Grid x:Name="LayoutRoot" Background="White"> <Grid.RowDefinitions> <RowDefinition Height="30" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <ComboBox x:Name="SearchesComboBox" Width="150"> <ComboBox.ItemContainerStyle> <Style TargetType="ComboBoxItem"> <Setter Property="HorizontalContentAlignment" Value="Stretch"/> </Style> </ComboBox.ItemContainerStyle> <ComboBox.ItemTemplate> <DataTemplate> <Border BorderBrush="Black" BorderThickness="1"> <TextBlock Text="{Binding}" Margin="2" /> </Border> </DataTemplate> </ComboBox.ItemTemplate> <sys:String>Two</sys:String> <sys:String>Four</sys:String> <sys:String>Six</sys:String> </ComboBox> </Grid>
07-02-2009 1:32 PM |
Blah. I solved my problem. There is a binding bug in the ListBoxItem template. I fixed it by copying the template out of the DLL and modifying the ContentPresenter to use a TemplateBinding instead of being hard-coded to "Left". It sucks, but I don't know of any other way :(
The full solution is here: http://tinyurl.com/nyusfd