Skip to main content
Version: 11.0.x

Add Some Layout

Avalonia provides a range of built-in controls to help you layout the visual elements of an application. On this page you will see how to use some of these layout controls.

At this stage, your application has a single button located in the content zone of the main window.

In fact an Avalonia window allows only a single other control in its content zone. So to add the multiple visual elements required for most applications, you will need to use one of the built-in layout controls that allows multiple other controls inside its content zone.

Stack Panel

The stack panel control allows multiple controls in its content zone, and arranges them in a vertical stack in the sequence they are defined in the XAML.


Text Block

The text block control gives you full control over the styling of the text it contains.

To take the example forwards, add a stack panel as follows (you can include the existing the button XAML).

<Border Margin="5"
<TextBlock Margin="5"
Text="Temperature Converter">
<Button HorizontalAlignment="Center">Calculate</Button>

You can explore the other layout controls in Avalonia from the reference here.

On the next page, you will add some inputs to the middle of the window.