NotificationViewModel.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using Avalonia.Controls.Notifications;
  2. using MiniMvvm;
  3. namespace ControlCatalog.ViewModels
  4. {
  5. public class NotificationViewModel
  6. {
  7. public WindowNotificationManager? NotificationManager { get; set; }
  8. public NotificationViewModel()
  9. {
  10. ShowCustomManagedNotificationCommand = MiniCommand.Create(() =>
  11. {
  12. NotificationManager?.Show(new NotificationViewModel() { Title = "Hey There!", Message = "Did you know that Avalonia now supports Custom In-Window Notifications?" , NotificationManager = NotificationManager});
  13. });
  14. ShowManagedNotificationCommand = MiniCommand.Create(() =>
  15. {
  16. NotificationManager?.Show(new Avalonia.Controls.Notifications.Notification("Welcome", "Avalonia now supports Notifications.", NotificationType.Information));
  17. });
  18. ShowNativeNotificationCommand = MiniCommand.Create(() =>
  19. {
  20. NotificationManager?.Show(new Avalonia.Controls.Notifications.Notification("Error", "Native Notifications are not quite ready. Coming soon.", NotificationType.Error));
  21. });
  22. YesCommand = MiniCommand.Create(() =>
  23. {
  24. NotificationManager?.Show(new Avalonia.Controls.Notifications.Notification("Avalonia Notifications", "Start adding notifications to your app today."));
  25. });
  26. NoCommand = MiniCommand.Create(() =>
  27. {
  28. NotificationManager?.Show(new Avalonia.Controls.Notifications.Notification("Avalonia Notifications", "Start adding notifications to your app today. To find out more visit..."));
  29. });
  30. }
  31. public string? Title { get; set; }
  32. public string? Message { get; set; }
  33. public MiniCommand YesCommand { get; }
  34. public MiniCommand NoCommand { get; }
  35. public MiniCommand ShowCustomManagedNotificationCommand { get; }
  36. public MiniCommand ShowManagedNotificationCommand { get; }
  37. public MiniCommand ShowNativeNotificationCommand { get; }
  38. }
  39. }