1
0

NotificationViewModel.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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}, NotificationType.Warning);
  13. });
  14. ShowManagedNotificationCommand = MiniCommand.Create(() =>
  15. {
  16. NotificationManager?.Show(new Avalonia.Controls.Notifications.Notification("Welcome", "Avalonia now supports Notifications.", NotificationType.Information));
  17. });
  18. YesCommand = MiniCommand.Create(() =>
  19. {
  20. NotificationManager?.Show(new Avalonia.Controls.Notifications.Notification("Avalonia Notifications", "Start adding notifications to your app today."));
  21. });
  22. NoCommand = MiniCommand.Create(() =>
  23. {
  24. NotificationManager?.Show(new Avalonia.Controls.Notifications.Notification("Avalonia Notifications", "Start adding notifications to your app today. To find out more visit..."));
  25. });
  26. }
  27. public string? Title { get; set; }
  28. public string? Message { get; set; }
  29. public MiniCommand YesCommand { get; }
  30. public MiniCommand NoCommand { get; }
  31. public MiniCommand ShowCustomManagedNotificationCommand { get; }
  32. public MiniCommand ShowManagedNotificationCommand { get; }
  33. }
  34. }