C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Next: I dragged four Button elements to the WrapPanel. These become sub-controls. I adjusted the Content, Margin and added some Padding.
Finally: I ran the program. When I resized the window, the WrapPanel "wraps" the Button elements as though they are text.
Tip: This makes the Buttons visible on narrow windows. It makes the user interface more versatile.
Example markup: XAML
<Window x:Class="WpfApplication19.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>
<WrapPanel
HorizontalAlignment="Stretch"
Height="299"
Margin="10"
VerticalAlignment="Top">
<Button Content="Button 1" Width="75" Margin="10" Padding="10"/>
<Button Content="Button 2" Width="75" Margin="10" Padding="10"/>
<Button Content="Button 3" Width="75" Margin="10" Padding="10"/>
<Button Content="Button 4" Width="75" Margin="10" Padding="10"/>
</WrapPanel>
</Grid>
</Window>