using Avalonia; using Avalonia.Controls; using Ursa.Controls; using Ursa.Demo.ViewModels; namespace Ursa.Demo.Pages; public partial class NotificationDemo : UserControl { public NotificationDemo() { InitializeComponent(); } protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) { base.OnAttachedToVisualTree(e); if (DataContext is not NotificationDemoViewModel vm) return; var topLevel = TopLevel.GetTopLevel(this); vm.NotificationManager = WindowNotificationManager.TryGetNotificationManager(topLevel, out var manager) ? manager : new WindowNotificationManager(topLevel); } }