How to get controls in WPF to fill available space?

前端 未结 4 2103
面向向阳花
面向向阳花 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:04

    There are also some properties you can set to force a control to fill its available space when it would otherwise not do so. For example, you can say:

    HorizontalContentAlignment="Stretch"
    

    ... to force the contents of a control to stretch horizontally. Or you can say:

    HorizontalAlignment="Stretch"
    

    ... to force the control itself to stretch horizontally to fill its parent.

提交回复
热议问题