C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Left, Top: This is the first Button. It is on the left side of the window at the top.
Left, Bottom: This Button has a HorizontalAlignment of Left, and a vertical one of "Bottom," so it is at the bottom left.
Left, Center: The third button is located on the left edge, vertically centered. Its position changes as the window resizes.
Center, Center: This Button will always be located in the center of the window. Try resizing the window: it remained centered.
Right, Stretch: This Button uses Stretch for its VerticalAlignment. This means it expands to fill the vertical space.
Example markup: XAML
<Window x:Class="WpfApplication14.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button Content="Button"
HorizontalAlignment="Left" VerticalAlignment="Top" Width="75"/>
<Button Content="Button"
HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="75"/>
<Button Content="Button"
HorizontalAlignment="Left" VerticalAlignment="Center" Width="75"/>
<Button Content="Button"
HorizontalAlignment="Center" VerticalAlignment="Center" Width="75"/>
<Button Content="Button"
HorizontalAlignment="Right" VerticalAlignment="Stretch" Width="75"/>
</Grid>
</Window>
Tip: To have a control expand to fill the space, remove the "Width" or "Height" properties. They do not need to be specified.
Note: There are inconsistent parts. For example, a Button uses the "Content" attribute for its text, while a TextBox uses a Text attribute.