Skip to main content
  1. Developer Recipes/
  2. Window/

Resize a Window in Avalonia

·1 min· ·
Table of Contents

Set the Size in XAML
#

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="YourApp.MainWindow"
        Width="800" Height="600"><!-- Set the window size here -->

    <TextBlock Text="The window has been resized."
               HorizontalAlignment="Center"
               VerticalAlignment="Center"/>
</Window>

Use the Width property to set the window’s width and the Height property to set its height.

Set the Size in C#
#

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();

        Width = 800;
        Height = 600;
    }
}

Related