↓ メインコンテンツへスキップ
  1. Recipe / 逆引き/
  2. Window関連/

Avaloniaでウィンドウサイズを変更する

·1 分· ·
目次

XAMLで指定
#

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="YourApp.MainWindow"
        Width="800" Height="600"><!-- ここでウィンドウサイズを指定 -->

    <TextBlock Text="ウィンドウサイズを変更しました"
               HorizontalAlignment="Center"
               VerticalAlignment="Center"/>
</Window>

Width プロパティでウィンドウの横幅、Height プロパティでウィンドウの高さを指定できます。

C#で指定
#

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

        Width = 800;
        Height = 600;
    }
}

関連記事