C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Next: I dragged three Buttons to the DockPanel. I adjusted their heights and set their DockPanel.Dock attributes.
Dock: The DockPanel.Dock attribute handles four values: top, bottom, left and right. Only one can be specified.
Example markup: XAML
<Window x:Class="WpfApplication7.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>
<DockPanel HorizontalAlignment="Stretch" LastChildFill="False" Margin="0"
VerticalAlignment="Top">
<Button Content="Cat" Height="100" VerticalAlignment="Top" Width="75"
DockPanel.Dock="Left"/>
<Button Content="Dog" Height="100" VerticalAlignment="Top" Width="75"/>
<Button Content="Squirrel" Height="100" VerticalAlignment="Top" Width="75"
DockPanel.Dock="Right"/>
</DockPanel>
</Grid>
</Window>
Tip: The HorizontalAlignment property of the DockPanel is important for this behavior. It makes the DockPanel expand to the window size.