Documentation/docs/styling
Collin Alpert 0103d383a0
Fix typo in `ContentPresenter`
2022-03-01 17:31:42 +01:00
..
README.md GitBook: [master] 21 pages and 2 assets modified 2021-07-01 23:11:01 +00:00
resources.md GitBook: [master] 21 pages and 2 assets modified 2021-07-01 23:11:01 +00:00
selectors.md Update selectors.md 2021-11-28 21:34:02 +01:00
styles.md Fix typo in `ContentPresenter` 2022-03-01 17:31:42 +01:00
troubleshooting.md Update troubleshooting.md 2021-11-01 22:01:38 -04:00

README.md

🎨 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:

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Window.Styles>
        <Style Selector="TextBlock.h1">
            <Setter Property="FontSize" Value="24"/>
            <Setter Property="FontWeight" Value="Bold"/>
        </Style>
    </Window.Styles>

    <TextBlock Classes="h1">I'm a Heading!</TextBlock>
</Window>