mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-04-15 21:56:36 +08:00
fix: fix notification.
This commit is contained in:
@@ -12,7 +12,7 @@ namespace Semi.Avalonia.Demo.Pages;
|
||||
|
||||
public partial class NotificationDemo : UserControl
|
||||
{
|
||||
private MainWindow? _window;
|
||||
private WindowNotificationManager _manager;
|
||||
public NotificationDemo()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -21,14 +21,15 @@ public partial class NotificationDemo : UserControl
|
||||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
||||
{
|
||||
base.OnAttachedToVisualTree(e);
|
||||
_window = VisualRoot as MainWindow;
|
||||
var topLevel = TopLevel.GetTopLevel(this);
|
||||
_manager = new WindowNotificationManager(topLevel){ MaxItems = 3};
|
||||
}
|
||||
|
||||
private void InfoButton_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Button b && b.Content is string s && Enum.TryParse<NotificationType>(s, out NotificationType t))
|
||||
{
|
||||
_window?.Notify(t);
|
||||
_manager.Show(new Notification(t.ToString(), "This is message", t));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user