Files
Ursa.Avalonia/demo/Ursa.Demo/Pages/NotificationDemo.axaml.cs
2025-06-04 17:12:54 +08:00

24 lines
696 B
C#

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);
}
}