How can I anchor a combox box so that when I drag the splitter it will size automatically.
I tried using a stackpanel to no avail, and even setting the HorizontalAlignment and HorizontalContentAlignment to stretch; it does not work.
I need the combo box to be as wide as the section is dragged. In non wpf you just anchored the combo, in wpf that option is not available.
<StackPanel Orientation="Horizontal">
<Label Content="View By"
Padding="5"
Height="30" />
<ComboBox Name="ddSelector"
Height="25"
Width="auto"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
Margin="16,0,0,0" />
</StackPanel>
The stack panel is in row 0 and the grid splitter is in row 1.
<Grid.ColumnDefinitions>
<ColumnDefinition Width="275"></ColumnDefinition>
<ColumnDefinition Width="auto"></ColumnDefinition>
<ColumnDefinition Width="350"></ColumnDefinition>
<ColumnDefinition Width="auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<GridSplitter Width="5"
Margin="0,36,0,5"
BorderThickness="4"
BorderBrush="Transparent"
Grid.Column="1"
HorizontalContentAlignment="Center"
HorizontalAlignment="Center"
ResizeBehavior="PreviousAndNext"></GridSplitter>
Use a Grid instead of a StackPanel. This will do.