MainWindowViewModel.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Threading.Tasks;
  5. using Avalonia;
  6. using Avalonia.Controls.Notifications;
  7. using Avalonia.Threading;
  8. namespace ControlCatalog.ViewModels
  9. {
  10. class MainWindowViewModel
  11. {
  12. public MainWindowViewModel()
  13. {
  14. Dispatcher.UIThread.InvokeAsync(async () =>
  15. {
  16. await Task.Delay(5000);
  17. Application.Current.MainWindow.LocalNotificationManager.Show(new NotificationViewModel { Title = "Warning", Message = "Please save your work before closing." });
  18. await Task.Delay(1500);
  19. Application.Current.MainWindow.LocalNotificationManager.Show(new NotificationContent { Message = "Test2", Type = NotificationType.Error });
  20. await Task.Delay(2000);
  21. Application.Current.MainWindow.LocalNotificationManager.Show(new NotificationContent { Message = "Test3", Type = NotificationType.Warning });
  22. await Task.Delay(2500);
  23. Application.Current.MainWindow.LocalNotificationManager.Show(new NotificationContent { Message = "Test4", Type = NotificationType.Success });
  24. await Task.Delay(500);
  25. Application.Current.MainWindow.LocalNotificationManager.Show("Test5");
  26. });
  27. }
  28. }
  29. }