diff --git a/src/Avalonia.Controls/Notifications/IManagedNotificationManager.cs b/src/Avalonia.Controls/Notifications/IManagedNotificationManager.cs
index 5eba36dbe6..94d927f8ca 100644
--- a/src/Avalonia.Controls/Notifications/IManagedNotificationManager.cs
+++ b/src/Avalonia.Controls/Notifications/IManagedNotificationManager.cs
@@ -15,6 +15,12 @@ namespace Avalonia.Controls.Notifications
[NotClientImplementable]
public interface IManagedNotificationManager : INotificationManager
{
+ ///
+ /// Shows a notification.
+ ///
+ /// The content to be displayed.
+ void Show(object content);
+
///
/// Shows a notification.
///
@@ -25,7 +31,7 @@ namespace Avalonia.Controls.Notifications
/// 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,
+ NotificationType type,
TimeSpan? expiration = null,
Action? onClick = null,
Action? onClose = null,
diff --git a/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs b/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs
index 80931d1865..26ca8abb42 100644
--- a/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs
+++ b/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs
@@ -73,8 +73,8 @@ namespace Avalonia.Controls.Notifications
///
/// Initializes a new instance of the class.
///
- /// The visual that will host the control.
- public WindowNotificationManager(Visual? host) : this()
+ /// The TopLevel that will host the control.
+ public WindowNotificationManager(TopLevel? host) : this()
{
Host = host;
}
@@ -108,9 +108,22 @@ namespace Avalonia.Controls.Notifications
Show(content, content.Type, content.Expiration, content.OnClick, content.OnClose);
}
+ ///
+ public async void Show(object content)
+ {
+ if (content is INotification notification)
+ {
+ Show(notification, notification.Type, notification.Expiration, notification.OnClick, notification.OnClose);
+ }
+ else
+ {
+ Show(content, NotificationType.Information);
+ }
+ }
+
///
public async void Show(object content,
- NotificationType type = NotificationType.Information,
+ NotificationType type,
TimeSpan? expiration = null,
Action? onClick = null,
Action? onClose = null,
@@ -202,7 +215,7 @@ namespace Avalonia.Controls.Notifications
if (adornerLayer is not null)
{
- adornerLayer.Children.Add(this);
+ // adornerLayer.Children.Add(this);
AdornerLayer.SetAdornedElement(this, adornerLayer);
}
}