Primary WPF APIs:
FreezableBrush and geometry resourcesPrimary Avalonia APIs:
IImmutableBrush, ImmutableSolidColorBrush, etc.)Brushes and brush conversion (ToImmutable())Bitmap and image source assets| WPF | Avalonia |
|---|---|
Freezable.Freeze() for reuse |
prefer immutable brush/image resources and shared static resources |
| mutable brush in hot draw paths | convert to immutable where appropriate |
ImageSource resources |
Avalonia Bitmap/asset URI image sources |
WPF C#:
var brush = new SolidColorBrush(Colors.DodgerBlue);
if (brush.CanFreeze)
brush.Freeze();
Avalonia XAML:
<Border xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Background="DodgerBlue"
Width="120"
Height="40" />
using Avalonia.Media;
using Avalonia.Media.Immutable;
IImmutableSolidColorBrush accent = new ImmutableSolidColorBrush(Colors.DodgerBlue);
var mutable = new SolidColorBrush(Colors.DodgerBlue);
var immutable = mutable.ToImmutable();
Freezable API parity.