Skip to content

Upgrading to Avalonia v11

Damian edited this page Dec 8, 2022 · 9 revisions

Coming Soon!

This page will assist you with upgrading your application to the latest Avalonia v11, which is currently in preview.

DataTemplates and DataTypes

This is a breaking change that affects your Views.

Developers must define the DataType property of the DataTemplate and ItemTemplate elements.

Tips To Avoid Issues

Use CompileBindings

When using Compiled Bindings in your XAML, not only will your applications perform better, but it will also allow the compiler will throw an error immediately so that you do not get any surprises at runtime.

To use this feature, add the properties, x:CompileBindings="True" and x:DataType="vm:YOURVIEWMODEL" to the control/window element. Please see the official documentation for Compiled Bindings to better assist your project's needs.

Sample:

<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:vm="using:SampleMvvmApp.ViewModels"
             xmlns:system="clr-namespace:System;assembly=mscorlib"
             x:Class="SampleMvvmApp.Views.DashboardView"
             x:CompileBindings="True"
             x:DataType="vm:DashboardViewModel">
Clone this wiki locally