1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| public partial class DemoView : UserControl {
private WindowNotificationManager? _manager;
public DemoView() { InitializeComponent(); }
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) { base.OnAttachedToVisualTree(e); var topLevel = TopLevel.GetTopLevel(this); _manager = new WindowNotificationManager(topLevel){ MaxItems = 5}; }
private void Button_OnClick(object? sender, RoutedEventArgs e) { _manager?.Show(new Notification("错误信息标题", "错误信息的内容!", NotificationType.Error)); } }
|