WPF: How can I stretch the middle child in a DockPanel?

You need to set DockPanel.Dock attached property for your elements and leave TextBox as the last element: <RadioButton HorizontalAlignment=”Stretch” HorizontalContentAlignment=”Stretch”> <DockPanel LastChildFill=”True”> <TextBlock DockPanel.Dock=”Left” VerticalAlignment=”Center” Text=”in location:” /> <Button DockPanel.Dock=”Right” Margin=”10,0,0,0″ Padding=”3,0″ Content=”…” /> <TextBox Margin=”10,0,0,0″> Path string </TextBox> </DockPanel> </RadioButton>

What is the difference between a StackPanel and DockPanel in WPF?

Stack Panel: The StackPanel, as the name implies, arranges content either horizontally or vertically. Vertical is the default, but this can be changed using the Orientation property. Content is automatically stretched based on the orientation (see screenshot below), and this can be controlled by changing the HorizontalAlignment or VerticalAlignment properties. Dock Panel: The DockPanel is … Read more

How to get StackPanel’s children to fill maximum space downward?

It sounds like you want a StackPanel where the final element uses up all the remaining space. But why not use a DockPanel? Decorate the other elements in the DockPanel with DockPanel.Dock=”Top”, and then your help control can fill the remaining space. XAML: <DockPanel Width=”200″ Height=”200″ Background=”PowderBlue”> <TextBlock DockPanel.Dock=”Top”>Something</TextBlock> <TextBlock DockPanel.Dock=”Top”>Something else</TextBlock> <DockPanel HorizontalAlignment=”Stretch” VerticalAlignment=”Stretch” … Read more