🎨
Styling
​Styles in Avalonia are used to share property settings between controls. The Avalonia styling system can be thought of as a mix of CSS styling and WPF/UWP styling. At its most basic, a style consists of a selector and a collection of setters.
The following style selects any TextBlock in the Window with a h1 style class and sets its font size to 24 point and font weight to bold:
1
<Window xmlns="https://github.com/avaloniaui"
2
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
3
<Window.Styles>
4
<Style Selector="TextBlock.h1">
5
<Setter Property="FontSize" Value="24"/>
6
<Setter Property="FontWeight" Value="Bold"/>
7
</Style>
8
</Window.Styles>
9
​
10
<TextBlock Classes="h1">I'm a Heading!</TextBlock>
11
</Window>
Copied!
Last modified 4mo ago
Export as PDF
Copy link