diff --git a/src/Avalonia.Controls/Notifications/IManagedNotificationManager.cs b/src/Avalonia.Controls/Notifications/IManagedNotificationManager.cs index 8d1cb644be..5eba36dbe6 100644 --- a/src/Avalonia.Controls/Notifications/IManagedNotificationManager.cs +++ b/src/Avalonia.Controls/Notifications/IManagedNotificationManager.cs @@ -23,10 +23,12 @@ namespace Avalonia.Controls.Notifications /// the expiration time of the notification after which it will automatically close. If the value is then the notification will remain open until the user closes it. /// an Action to be run when the notification is clicked. /// an Action to be run when the notification is closed. + /// Style-classes to ba added to the notification card void Show(object content, NotificationType type = NotificationType.Information, TimeSpan? expiration = null, Action? onClick = null, - Action? onClose = null); + Action? onClose = null, + string[]? classes = null); } } diff --git a/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs b/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs index d764f2bd78..0b7a19707b 100644 --- a/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs +++ b/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs @@ -88,7 +88,8 @@ namespace Avalonia.Controls.Notifications NotificationType type = NotificationType.Information, TimeSpan? expiration = null, Action? onClick = null, - Action? onClose = null) + Action? onClose = null, + string[]? classes = null) { var notificationControl = new NotificationCard { @@ -96,6 +97,15 @@ namespace Avalonia.Controls.Notifications NotificationType = type }; + // Add style classes if any + if (classes != null) + { + foreach (var @class in classes) + { + notificationControl.Classes.Add(@class); + } + } + notificationControl.NotificationClosed += (sender, args) => { onClose?.Invoke();