Avalonia 12 breaking changes
This page lists all the breaking changes between Avalonia 11 and 12 and provides migration guidance and alternatives.
.NET support updated
Avalonia version 12 dropped support for .NET Framework and .NET Standard. Only .NET 8 and later are supported.
We recommend targeting .NET 10.
If your project targets Android or iOS, only .NET 10 is supported. This is to match the support Microsoft provides for the underlying .NET SDK.
Update your Avalonia projects to a supported .NET version.
Example:
-<TargetFramework>netstandard2.0</TargetFramework>
+<TargetFramework>net10.0</TargetFramework>
PR: #19869
Avalonia version 12
The major version of Avalonia is now 12, up from 11.
Upgrade all Avalonia package references to the latest 12 patch version, either in your favorite IDE or by editing the project files.
We recommend choosing the latest release from the official GitHub Releases page.
Example:
-<PackageReference Include="Avalonia" Version="11.3.12" />
+<PackageReference Include="Avalonia" Version="12.0.0" />
-<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.12" />
+<PackageReference Include="Avalonia.Themes.Fluent" Version="12.0.0" />
Avalonia.Diagnostics package removed
The Avalonia.Diagnostics package has been removed.
The Dev Tools included with Avalonia Accelerate should be used instead.
Remove the Avalonia.Diagnostics package from your projects and replace it with AvaloniaUI.DiagnosticsSupport.
To install the Accelerate Dev Tools, please follow our Dev Tools documentation.
Example:
Project file:
-<PackageReference Include="Avalonia.Diagnostics" Version="11.3.12" />
+<PackageReference Include="AvaloniaUI.DiagnosticsSupport" Version="2.2.0" />
Application file:
-AttachDevTools();
+AttachDeveloperTools();
PR: #20332
Binding class hierarchy changes
The binding class hierarchy has changed. Bindings defined in XAML files (e.g., {Binding}) are unaffected. However, you must update binding usages in C# code.
The IBinding interface has been removed. Its replacement is the BindingBase class.
All types of bindings now inherit from BindingBase: ReflectionBinding, CompiledBinding, TemplateBinding, and IndexerBinding. Adjust your usage accordingly; don't assume that a BindingBase instance represents only a "standard" binding.
The Binding class is kept for compatibility and always corresponds to ReflectionBinding. To create bindings in code, we recommend using the CompiledBinding and ReflectionBinding classes directly.
The InstancedBinding class has also been removed. Its direct equivalent is BindingExpressionBase, which represents a binding applied to a given object and property.
Example:
public record Item(string Value);
-var reflectionBinding = new Binding("SomeProperty");
var reflectionBinding = new ReflectionBinding(nameof(Item.Value));
+var compiledBinding = CompiledBinding.Create((Item item) => item.Value);
Compiled bindings are enabled by default
<AvaloniaUseCompiledBindingsByDefault> is now true by default.
Any Binding usage in XAML code now maps to CompiledBinding.
Avalonia's official templates explicitly enabled this flag in created projects for several years, so recent codebases should not be affected. However, if your project didn't define this flag, it was false in previous versions.
We recommend using compiled bindings whenever possible, as they are more performant than reflection bindings and are checked for correctness at build time.
PR: #19712
Binding plugins removed
The binding plugins were intended as an extensibility point for adding features to bindings. In practice, they were not working with compiled bindings and were effectively unused by most people.
Worse, users often had to turn off the default data annotations validation plugin because it conflicted with popular frameworks such as CommunityToolkit.Mvvm.
Starting with Avalonia v12, plugins are no longer configurable. The data annotations plugin is now disabled by default.
PR: #20623
Configurable text shaper
The text shaper is now configurable independently of the rendering engine. For most applications, this change should be transparent, as HarfBuzz is used by default when UsePlatformDetect is called on the AppBuilder.
However, if your project explicitly configures a rendering engine, such as Skia via UseSkia, an InvalidOperationException with the message No text shaping system configured might be thrown on startup. In this case, the project needs to be updated with a call to UseHarfBuzz on the AppBuilder.
Example:
Project file:
+<PackageReference Include="Avalonia.HarfBuzz" Version="12.0.0" />
Application file:
AppBuilder.Configure<App>()
.UseSkia()
+ .UseHarfBuzz()
PR: #19852
[Windows] Direct2D1 support removed
Avalonia no longer provides a Direct2D rendering backend. This package was not maintained, and did not have feature and performance parity with our Skia backend. The Skia backend is now the recommended rendering backend for all usages.
Example:
Project file:
-<PackageReference Include="Avalonia.Direct2D1" Version="11.3.12" />
+<PackageReference Include="Avalonia.Skia" Version="12.0.0" />
Application file:
AppBuilder.Configure<App>()
- .UseDirect2D1()
+ .UseSkia()
PR: #20132
[Android] App initialization changed
In Avalonia 12, the way an Android application and its activities are initialized has changed, allowing subsequent activities to properly use the Application class defined in your project.
- Change your main activity to inherit from
AvaloniaMainActivity(non-generic) instead ofAvaloniaMainActivity<TApp>(generic). - Add a new class deriving from
AvaloniaAndroidApplication<TApp>and apply the[Android.App.Application]attribute to it.
Example:
[Activity]
public class MainActivity :
-AvaloniaMainActivity<App>
+AvaloniaMainActivity
{
}
+[Application]
+public class AndroidApp : AvaloniaAndroidApplication<App>
+{
+ protected AndroidApp(IntPtr javaReference, JniHandleOwnership transfer)
+ : base(javaReference, transfer)
+ {
+ }
+}
PR: #18756