WPF: How to make controls stretch in a StackPanel? WPF: How to make controls stretch in a StackPanel? wpf wpf

WPF: How to make controls stretch in a StackPanel?


You want DockPanel instead:

<DockPanel DockPanel.Dock="Bottom" LastChildFill="True">    <TextBlock DockPanel.Dock="Right" ... />    <Slider ... /></DockPanel>

DockPanel gets you the "Anchor" functionality you want. StackPanel simply stacks things next to each other.

I notice from your code block that your StackPanel is already docked inside a dockpanel, so I've included the same docking attribute in my code sample above.