Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define a separate set of styles for each platform/OS in Avalonia?

Is there a way to apply different styles depending on the operation system? How does one define separate themes for Windows, macOS and Linux?

like image 767
x2bool Avatar asked Sep 03 '25 02:09

x2bool


1 Answers

There is currently only one "default" theme, platform-specific themes are planned, but not yet implemented.

If you want per-platform themes/styles, you need to add them to your Application.Styles manually inside Application.Initialize using StyleInclude class (See App.xaml from application template). For platform detection you can use AvaloniaLocator.Current.GetService<IRuntimePlatform>().GetRuntimeInfo().OperatingSystem.

like image 195
kekekeks Avatar answered Sep 07 '25 00:09

kekekeks