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

Change the Window Background Color in Avalonia

·1 min· ·
Table of Contents

Set the Background Color in XAML
#

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://microsoft.com"
        x:Class="YourApp.MainWindow"
        Title="YourApp"
        Width="400" Height="300"
        Background="Black"> <!-- Set the background color here -->
        
    <TextBlock Text="The background color has been changed." HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Window>

Set the Background property of the Window to a color name or a hexadecimal color code to change the window’s background color.

Common Colors
#

You can specify either a color name or a hexadecimal color code for the Background property. The following table lists some commonly used colors for user interfaces.

色見本 日本語名 カラー名 カラーコード
White #FFFFFF
Black #000000
透明 Transparent #00FFFFFF
ホワイトスモーク WhiteSmoke #F5F5F5
ライトグレー LightGray #D3D3D3
グレー Gray #808080
ダークグレー DarkGray #A9A9A9
ダークスレートグレー DarkSlateGray #2F4F4F
Blue #0000FF
ロイヤルブルー RoyalBlue #4169E1
スチールブルー SteelBlue #4682B4
スカイブルー SkyBlue #87CEEB
Red #FF0000
クリムゾン Crimson #DC143C
オレンジ Orange #FFA500
ゴールド Gold #FFD700
Yellow #FFFF00
Green #008000
ライム Lime #00FF00
フォレストグリーン ForestGreen #228B22
シーグリーン SeaGreen #2E8B57
ティール Teal #008080
Purple #800080
マゼンタ Magenta #FF00FF
ピンク Pink #FFC0CB
ブラウン Brown #A52A2A
ベージュ Beige #F5F5DC
アイボリー Ivory #FFFFF0
ターコイズ Turquoise #40E0D0
ネイビー Navy #000080

Related