开发者

WPF: Control that never causes children to NOT consume all available space

开发者 https://www.devze.com 2022-12-19 11:22 出处:网络
Right now I have a problem with StackPanels inside DockPanels. Often the StackPanel is taller than necessary for the contents, s开发者_如何学Pythono the contents are stretched.

Right now I have a problem with StackPanels inside DockPanels. Often the StackPanel is taller than necessary for the contents, s开发者_如何学Pythono the contents are stretched.

Is there something I can place in or around the StackPanel to mean "don't cause children to consume all avaialble space".


AFAIK the contents of the StackPanel do not "stretch" to fill it, anymore than any other control. i.e. the stretch to fill will be controlled by the HorizontalAlignment and VerticalAlignment of the child elements.

The default is usually Stretch. Try setting it to Left etc.


Well, what do you want your StackPanel to do? If you want it to only consume the visible space, use a grid. If you want to scroll the contents of your StackPanel, I believe you can put it in a ScrollViewer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号