What is the difference between HorizontalAlignment and HorizontalContentAlignment in WPF?

后端 未结 3 1997
甜味超标
甜味超标 2020-12-15 17:28

What is the difference between:

  • HorizontalAlignment=\"Stretch\"
  • HorizontalContentAlignment=\"Stretch\"

in a

3条回答
  •  心在旅途
    2020-12-15 18:07

    HorizontalContentAlignment and VerticalContentAlignment are used with Content Controls which apply these to its content. For example in the following code the Content Control Button will align its content(which is a string in this case and can be any arbitrary object) to center.

    HorizontalAlignment and VerticalAlignment are used with child elements when these are inside a Panel. Panel will arrange its children based on these properties of child elements. In the following code the Panel (StackPanel) will align its child (Button) to right.

    
        

提交回复
热议问题