Files
Ursa.Avalonia/demo/Ursa.Demo/Pages/NotificationDemo.axaml.cs

29 lines
824 B
C#

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