Manual Setup of Headless Platform
warning
Install Packages
To set up the Headless platform, you need to install two packages:
- Avalonia.Headless, which also includes Avalonia.
- Avalonia.Themes.Fluent, as even headless controls need a theme.
tip
The Headless platform doesn't require any specific theme, and it is possible to swap FluentTheme with any other.
Setup Application
As in any other Avalonia app, an Application instance needs to be created, and themes need to be applied. When using the Headless platform, the setup is not much different from a regular Avalonia app and can mostly be reused.
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Tests.App">
<Application.Styles>
<FluentTheme />
</Application.Styles>
</Application>
And the code:
using Avalonia;
using Avalonia.Headless;
public class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
}