WPF: How to make controls stretch in a StackPanel?

做~自己de王妃 提交于 2019-12-03 05:36:10

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!