NativeTheme.Avalonia 1.0.1

dotnet add package NativeTheme.Avalonia --version 1.0.1
                    
NuGet\Install-Package NativeTheme.Avalonia -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NativeTheme.Avalonia" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NativeTheme.Avalonia" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="NativeTheme.Avalonia" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NativeTheme.Avalonia --version 1.0.1
                    
#r "nuget: NativeTheme.Avalonia, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NativeTheme.Avalonia@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NativeTheme.Avalonia&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=NativeTheme.Avalonia&version=1.0.1
                    
Install as a Cake Tool

NativeTheme.Avalonia

Avalonia styles that paint common controls with the current Windows UxTheme visual style. Uncovered controls fall through to Avalonia's SimpleTheme.

Constructing the theme also installs a DirectWrite/GDI compatibility patch so text metrics and hinting match the native Windows rendering used by the controls.

Originally built for Skymu.

The GDI patch modifies COM v-tables at runtime. It is applied automatically when NativeTheme is constructed, before the theme reads system fonts and metrics.

Install

dotnet add package NativeTheme.Avalonia

Apply the theme in XAML

NativeTheme derives from Avalonia.Styling.Styles and has a parameterless constructor, so it can be used like any other Avalonia theme:

<Application
    x:Class="MyApp.App"
    xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:native="clr-namespace:NativeTheme.Avalonia;assembly=NativeTheme.Avalonia">

    <Application.Styles>
        <native:NativeTheme />
    </Application.Styles>
</Application>

By default, NativeTheme adds SimpleTheme underneath itself as a fallback for controls it does not paint natively. If the application already has a base theme, disable the fallback:

<native:NativeTheme IncludeSimpleTheme="False" />

Colors, metrics, fonts, and control sizes are read from Windows when the theme is constructed. For that reason there is no static .axaml file to load with StyleInclude.

Code usage

If you build styles in code, instantiate the theme directly:

using NativeTheme.Avalonia;

Styles styles = new NativeTheme();

To omit the SimpleTheme fallback:

Styles styles = new NativeTheme(includeSimpleTheme: false);

GDI font patch

The patch is installed by the NativeTheme constructor, so no extra call in Main is required:

var theme = new NativeTheme();

Explicit entry points remain available if you want the patch without creating the theme:

using NativeTheme.Avalonia;

NativeTheme.InstallGdiPatch(); // same as GdiPatch.Install()

Both are idempotent, best-effort, and no-ops on non-Windows platforms. Installation failures are written to Debug rather than preventing the theme from loading. GdiPatch.KeepKerning is reserved for an optional shaped-buffer adjustment that is not installed by this package.

Reacting to system theme changes

When the Windows visual style or DPI changes, clear the native bitmap cache and repaint:

NativeTheme.Invalidate();

ThemePart controls subscribe to NativeTheme.Changed and repaint themselves automatically.

Platform notes

The native control rendering requires Windows with an active visual style. On other platforms, the theme has no native styles to apply and the SimpleTheme fallback remains available.

Build and pack

dotnet build NativeTheme.Avalonia.sln
dotnet pack src/NativeTheme.Avalonia/NativeTheme.Avalonia.csproj -c Release

The NuGet package is written to src/NativeTheme.Avalonia/bin/Release.

License

MIT. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 0 11/28/2026
1.0.0 0 11/28/2026