mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-04-06 01:06:36 +08:00
33 lines
850 B
C#
33 lines
850 B
C#
|
|
using System;
|
||
|
|
using Avalonia;
|
||
|
|
using Avalonia.Controls;
|
||
|
|
using Avalonia.Controls.Notifications;
|
||
|
|
using Avalonia.Controls.Presenters;
|
||
|
|
using Avalonia.Interactivity;
|
||
|
|
using Avalonia.Markup.Xaml;
|
||
|
|
using Avalonia.VisualTree;
|
||
|
|
|
||
|
|
namespace Semi.Avalonia.Demo.Pages;
|
||
|
|
|
||
|
|
public partial class NotificationDemo : UserControl
|
||
|
|
{
|
||
|
|
private MainWindow? _window;
|
||
|
|
public NotificationDemo()
|
||
|
|
{
|
||
|
|
InitializeComponent();
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
||
|
|
{
|
||
|
|
base.OnAttachedToVisualTree(e);
|
||
|
|
_window = VisualRoot as MainWindow;
|
||
|
|
}
|
||
|
|
|
||
|
|
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);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|