Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v11-Prev 5 - Update Window Notification Sample #42

Merged
merged 4 commits into from
Feb 5, 2023

Conversation

DamianSuess
Copy link
Collaborator

@DamianSuess DamianSuess commented Feb 5, 2023

Feature Includes

  • Upgrade Window Notification Manager Pop-Up example
  • Breaking change in Avalonia PR 9277 for more information

What Changed

The reason for the change was to provide support for single-view platforms, where a "desktop" window is not available.

Developers can no longer initialize the WindowNotificationManager in the main (shell) window's .axaml.cs, nor pass in main window's instance (this).

New Implementation

The initialization must now be performed in your UserControl's .axaml.cs file. The sample below is borrowed from the SampleMvvmApp which uses a NotificationService

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

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

@DamianSuess DamianSuess added the enhancement New feature or request label Feb 5, 2023
@DamianSuess DamianSuess self-assigned this Feb 5, 2023
@DamianSuess DamianSuess linked an issue Feb 5, 2023 that may be closed by this pull request
7 tasks
@DamianSuess DamianSuess merged commit 13fc4e2 into develop Feb 5, 2023
@DamianSuess DamianSuess deleted the feature/v11prev5-Notifications branch February 5, 2023 15:23
@DamianSuess DamianSuess changed the title Update Window Notification Sample v11 Prev 5 - Update Window Notification Sample Feb 6, 2023
@DamianSuess DamianSuess changed the title v11 Prev 5 - Update Window Notification Sample v11-Prev 5 - Update Window Notification Sample Feb 6, 2023
@DamianSuess DamianSuess added this to the asdf milestone Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Avalonia v11 Preview 5
1 participant