Skip to content

Latest commit

 

History

History
109 lines (80 loc) · 5.04 KB

Upgrading-to-Avalonia-11.md

File metadata and controls

109 lines (80 loc) · 5.04 KB

Upgrading to Avalonia v11 Preview

This document outlines the path to upgrading your projects from Avalonia v0.10.18 to v11.xx. Please read over this document and suggest changes to help improve the documentation. After all, we learn from one another.

Check out Avalonia's Breaking Changes wiki page for more information

11.0 Preview 8

Breaking Changes

  • Converted ItemsControlRegionAdapter to use ItemsSource.
    • As of Avalonia PR #10827, ItemsControl.Items is readonly and should use ItemsControls.ItemsSource (PR #10590)

11.0 Preview 5

NOTE: Breaking Changes Ahead!

Breaking Changes

Breaking Changes wiki

  • Interface Deprecation
    • See, PR #9553
    • I.E. IAvaloniaObject -> AvalonObject, and more.
  • WindowNotificationManager Pop-Ups are no longer working in 11 Preview 5
    • See, PR #9277 and example
    • Implementation example below
    • The case was for "single view platforms" and not just Desktops which have a Window object.
  • Themes:
    • Themes must be download as part of a separate package and App.axaml implementation has changed.
    • User MUST set a theme in App.axaml, otherwise the window's contents may be transparent
    • See, PR# 8148, PR #8166, Issue #5593
    • NEW: <SimpleTheme />
    • OLD: <SimpleTheme Mode="Light" />
    • Both Avalonia.Themes.Fluent and Avalonia.Themes.Simple (formally, Default) are not a part of the main Avalonia nuget package anymore. You need to add a PackageReference to include either of these packages or both.
    • Its been observed that when setting a background image in your control or window, all of the controls will appear cloudy. Upgrade or defect?

Updates

  • NEW: IDialogWindow now implements WindowClosingEventArgs.
    • See, Issue #9524, PR #9715
    • This affects IDialogWindow implementation of public event EventHandler<WindowClosingEventArgs>? Closing;
  • Avalonia.ReactiveUI.Events.

WindowNotificationManager Example

Previously, users had to set the HostWindow inside the main shell Window as you see below. Now, users can define this from any UserControl view by simply providing notifyService.SetHostWindow(TopLevel.GetTopLevel(this)) in the view's .axaml.cs override void OnAttachedToVisualTree(..) method.

public partial class DashboardView : UserControl
{
  public DashboardView()
  {
    InitializeComponent();
  }

  protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
  {
    base.OnAttachedToVisualTree(e);

    // Initialize the WindowNotificationManager with the MainWindow
    var notifyService = ContainerLocator.Current.Resolve<INotificationService>();
    notifyService.SetHostWindow(TopLevel.GetTopLevel(this));
  }
}

Known Issues

  • Themes in sample are showing up cloudy
  • Selected ListView item still appears after clearing the List
    • STATUS: Needs reported
    • Reproduce:
      • Add items to ListView to fill 2+ pages
      • Scroll down to select item
      • Clear list
      • Resize window to show area previous now shown
    • Result:
      • Selected item still appears in list despite items removed from collection

Themes

When using Fluent theme, you no longer has a Mode attribute.

  <!-- New -->
  <FluentTheme />

  <!-- Old -->
  <FluentTheme Mode="Light" />

11.0 Preview 4

DataTemplates

DataTemplates now require a DataType to be defined. This actually improves intellisense of your XAML and loading times with MVVM.

As a workaround for ListViews, you can use the ItemTemplate which does not require the definition of a DataType.