This release brings features such as a new theme, backdrop effects, a more succinct way to declare Avalonia properties, .NET 11 support, and more! It also includes many performance improvements.
New features
Fluent2: a new default theme
Historically, Avalonia has been using the Fluent design language introduced by Microsoft in Windows 10. That design has evolved over the years, with a much nicer-looking version 2 used in Windows 11, but Avalonia wasn't updated. This is no longer the case with Avalonia 12.2, where you can enjoy the beautiful new Fluent2 theme! (PR #21771)
Since this theme provides a different look and feel, it's a separate package you have to opt in to: reference the Avalonia.Themes.Fluent2 package and use <Fluent2Theme /> instead of <FluentTheme /> in your App.axaml file. If you're starting a new project, Avalonia's templates now use Fluent2 by default.
Backdrop effects
Backdrop effects are now available (PR #21826), allowing you to add some nice eye candy to your applications, such as background blur! As always with Avalonia, this effect is GPU-accelerated and optimized using various invalidation and caching techniques so that your app continues to run smoothly.
.NET 11 support
.NET 11 has been freshly released. It contains very few breaking changes, and Avalonia needed no adjustments for desktop and mobile: your applications will continue to run as expected, even with the .NET 10 builds. We still encourage you to update to Avalonia 12.2 to get all the other added benefits listed in this post!
However, the story is different in the WASM world, where numerous runtime changes occurred. We made all the necessary modifications to support this new scenario in Avalonia 12.2 (PR #22196). If you're using the Avalonia.Browser package and plan to target .NET 11, you can update right now.
Source generator for Avalonia properties
Inherited from WPF, Avalonia properties have always been quite verbose to declare. First, the field declaring the StyledProperty or DirectProperty needs to be written. Then its accessor, a standard CLR property or a couple of methods for an attached property.
This boilerplate is no longer required! Thanks to the addition of partial properties in C# 13, Avalonia now comes with a source generator that generates the details for you (PR #21797).
Before:
public static readonly StyledProperty<double> RowSpacingProperty =
AvaloniaProperty.Register<Grid, double>(nameof(RowSpacing));
public double RowSpacing
{
get => GetValue(RowSpacingProperty);
set => SetValue(RowSpacingProperty, value);
}
public static readonly AttachedProperty<int> RowSpanProperty =
AvaloniaProperty.RegisterAttached<Grid, Control, int>("RowSpan", defaultValue: 1);
public static void SetRowSpan(Control element, int value)
=> element.SetValue(RowSpanProperty, value);
public static int GetRowSpan(Control element)
=> element.GetValue(RowSpanProperty);After:
[GeneratedStyledProperty]
public partial double RowSpacing { get; set; }
[GeneratedAttachedProperty(DefaultValue = 1)]
public static partial int GetRowSpan(Control element);FlexPanel
FlexPanel brings the CSS flexbox layout model to Avalonia. Layouts that used to require nested panels or custom code, like a card grid that adapts to any width, can now use this new control.
This control was initially contributed by jp2masa in our Avalonia.Labs project, which contains possible future controls and experiments. It now lives inside the main repository (PR #20263), and you can now use it without any additional package reference.
Rendering
Avalonia already supports composition animations and custom composition visuals. Both run on the render thread, so rendering stays smooth even when the UI thread is busy. Contributor zxbmmmmmmmmm has now added composition brushes so that brushes can be animated on the render thread too (PR #20181).
In the OpenGL backend, a new context management API is introduced, opening up more scenarios, such as creating OpenGL contexts not bound to a particular control (PR #21853).
It's also now possible to import Linux dma-buf file descriptors into the EGL backend, enabling the compositor to consume GPU images produced by other APIs such as Vulkan. (PR #21611)
Geometry hit testing
Avalonia 12.2 extends the existing point-based hit testing infrastructure to support testing against geometric shapes. This enables you to query visuals intersecting arbitrary geometries (ellipses, custom paths, etc.) rather than just single points (PR #21768).
Android desktop mode
Android recently shipped a new Desktop Mode. With the mouse becoming more important in this mode, Avalonia added support for cross-process drag-and-drop (PR #22451) and cursors (PR #22438).
Misc
- Key events now include the text actually produced by the keyboard layout, with and without modifiers included, as well as platform key data (PR #22628).
CalendarandCalendarDatePickercan optionally show a week-number column using the newIsWeekNumberVisibleproperty (PR #21981).WrapPanelgains new alignments:Justify(equal spacing between items),Stretch(items stretched to fill each row/column except the last) andStretchAll(every row/column, including the last) (PR #20549 by contributor Poker-sang).- A new
InputPaneAwareDecoratorcontrol keeps its content visible when the on-screen keyboard opens (PR #21566). INavigationgains overloads that accept a parameter, and generic extensions that create the page for you (PR #22010).- Visible title bar elements when
ExtendClientAreaToDecorationsHintis set are now configurable usingWindowDrawnDecorations.TitleBarDecorations. (#21969). - The "primary" selection is now exposed under X11 (PR #21849).
Performance improvements
Performance has always been central to Avalonia. With every new version, it keeps improving, and Avalonia 12.2 is no different!
Rendering
General
The EGL rendering backend now supports partial presentation – when the underlying driver implements the necessary extensions – to render updates in place instead of through an intermediate layer, which saves a full-screen blit per frame (PR #22501). In low-powered embedded devices, we measured up to a 25% increase in FPS.
The Skia renderer no longer allocates an extra surface per opacity mask, reducing the number of blits required in some situations. In one specific project, this change increased the FPS by 50% (PR #22798)!
Windows
On Windows, a new opt-in Win32PlatformOptions.UseCompositionSwapChain setting enables DWM to use independent flips and lower latency (PR #22115).
Linux
On X11, an opt-in X11PlatformOptions.UseXShmFramebuffer option initially contributed by lindexi enables passing frames to the X server through shared memory when software rendering is used, improving framerate (PR #21625).
When using DRM rendering and a screen rotation, the compositor now adjusts its output to match the surface orientation, avoiding an extra full-screen blit (PR #22499).
Another DRM improvement is non-blocking page flips, contributed by orestbida. The backend waits for the previous page flip rather than the one it just queued. On low-powered devices with vsync enabled, the framerate now approaches the native refresh rate, with up to 30% improvements measured (PR #22566).
iOS
Rendering is no longer capped at 60 FPS on iOS. NicholasLachapelle from our sponsor Devolutions implemented high-refresh-rate support, so newer devices using ProMotion can render frames and handle input at 120 Hz. (PR #22395, PR #22412)
Bindings
When the binding is simple, compiled bindings now use new typed expressions under the hood, avoiding boxing of bound values and reducing memory allocations in this area by up to 45% (PR #21552).
On top of that, for bindings with more complex requirements that can't use typed expressions, contributor NathanDrake2406 added caching of boxed boolean values (PR #21878).
XAML
Runtime performance isn't everything. File size is also an important metric. Avalonia's XAML compiler generates accessors for each member used in bindings, and that can quickly add up in complex applications. Usages of such accessors now go through a shared runtime helper, resulting in a drastic reduction in IL size (PR #22676).
Each generated accessor also needs a metadata name, which used to be derived from the full member name. Since it's not used at all at runtime, release builds now reduce these by default to a few characters (#22674).
Together, those two changes reduced the size of assemblies containing compiled XAML by almost 25% for one of our partners.
Themes
Control themes include many different resources across multiple dictionaries, and Avalonia was already merging several of them at build time for faster lookup. With Avalonia 12.2, this step goes further by moving the resources closer to the root, improving the time it takes to retrieve a given resource. Looking up all resources inside the Fluent2 theme is now 1.8x faster (PR #22637)!
Fonts
Some fonts don't provide alternate faces such as bold or italic. In this case, Avalonia simulates these when they're requested, but this used to require an extra copy of the font file in memory. This is no longer the case, reducing overall memory usage (PR #22773).
WASM
Input is now passed directly via an in-memory queue instead of going through JavaScript-to-.NET interop calls for each event, improving responsiveness when the device is slow (PR #22478).
In a similar area, dispatcher calls are now faster by using modern APIs such as MessageChannel (PR #22290).
Changelog
Avalonia 12.2 also contains bug fixes and other minor enhancements. Read the complete changelog for details.
Thanks to everyone who contributed to this release!
