Understanding Layouts in WinUI 3
WinUI 3 provides a powerful set of layout panels that let you arrange UI elements precisely and responsively. Whether you need a fixed grid, a flexible stack, or complex relative positioning, WinUI 3 has you covered.
Key Layout Panels
- Grid – Two‑dimensional layout with rows and columns.
- StackPanel – Simple vertical or horizontal stacking.
- RelativePanel – Position children relative to each other.
- VariableSizedWrapGrid – Wrap‑content grid that supports spanning.
Sample Grid Layout
<Grid RowDefinitions="Auto,*,Auto" ColumnDefinitions="2*,*">
<TextBlock Grid.Row="0" Grid.ColumnSpan="2" Text="Header"/>
<StackPanel Grid.Row="1" Grid.Column="0" Orientation="Vertical">
<Button Content="Button 1"/>
<Button Content="Button 2"/>
</StackPanel>
<ListView Grid.Row="1" Grid.Column="1"/>
<TextBlock Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Text="Footer"/>
</Grid>Live Demo
Header
- Item A
- Item B
- Item C
Footer