Alignment
The HorizontalAlignment
and VerticalAlignment
properties enable an element to control what it does with any extra space that its parent panel gives it. Each property has a corresponding enumeration with the same name, giving the following options:
→ HorizontalAlignment—Left
, Center
, Right
, and Stretch
→ VerticalAlignment—Top
, Center
, Bottom
, and Stretch
Stretch
is the default value for both properties, although various controls override the setting. The effects of HorizontalAlignment
can easily be seen by placing a few Button
s in a StackPanel
(a panel described further in the next chapter) and marking them with each value from the enumeration:
<StackPanel> <Button HorizontalAlignment ="Left" Content ...
Get Universal Windows® Apps with XAML and C# Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.