How to get controls in WPF to fill available space?

前端 未结 4 2109
面向向阳花
面向向阳花 2020-11-27 09:47

Some WPF controls (like the Button) seem to happily consume all the available space in its\' container if you don\'t specify the height it is to have.

A

4条回答
  •  误落风尘
    2020-11-27 10:03

    Well, I figured it out myself, right after posting, which is the most embarassing way. :)

    It seems every member of a StackPanel will simply fill its minimum requested size.

    In the DockPanel, I had docked things in the wrong order. If the TextBox or ListBox is the only docked item without an alignment, or if they are the last added, they WILL fill the remaining space as wanted.

    I would love to see a more elegant method of handling this, but it will do.

提交回复
热议问题