How to show notifications in an app #18510
-
I'm writing an application that will mostly be in minimized state and I need the application to display notifications on the screen, like notifications that show messengers, is there something like this in Avalonia UI? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 8 replies
-
Try HandyControl: https://github.com/HandyOrg/HandyControl |
Beta Was this translation helpful? Give feedback.
-
Avalonia has no built in toast API. You can write your own code somewhat easily for most platforms to do it. For Linux, there is a DBUS API you can use. https://specifications.freedesktop.org/notification-spec/latest/ Windows has many different toast APIs available. Android and iOS should also be supported by Xamarin/MAUI essentials. Not sure about Mac. |
Beta Was this translation helpful? Give feedback.
-
If you are just targeting windows then I have found Microsoft.Toolkit.Uwp.Notifications is pretty straight forward to use. |
Beta Was this translation helpful? Give feedback.
-
This is what i use, i inject the service in each project The abstraction
For Android
For iOS
For macOS
For Windows
|
Beta Was this translation helpful? Give feedback.
-
Preview:Code:var wnm = new WindowNotificationManager(this)
{
// Position = NotificationPosition.TopRight,
Margin = new Thickness(20,40)
};
wnm.Show(
new Notification
{
Title = "Title 1",
Message = "Message 1",
Expiration = TimeSpan.FromSeconds(5)
});
wnm.Show(
new Notification
{
Title = "Title 2",
Message = "Message 2",
Expiration = TimeSpan.FromSeconds(5)
});
wnm.Show(
new Notification
{
Title = "Title 3",
Message = "Message 3",
Expiration = TimeSpan.FromSeconds(5)
}); |
Beta Was this translation helpful? Give feedback.
-
You can check native notifications from Avalonia.Labs package. A simple sample is here: https://github.com/AvaloniaUI/Avalonia.Labs/blob/main/samples/Avalonia.Labs.Catalog/ViewModels/NativeNotificationsViewModel.cs It's an experimental package. If you find any issues - please report on the Avalonia.Labs repository. |
Beta Was this translation helpful? Give feedback.
You can check native notifications from Avalonia.Labs package. A simple sample is here: https://github.com/AvaloniaUI/Avalonia.Labs/blob/main/samples/Avalonia.Labs.Catalog/ViewModels/NativeNotificationsViewModel.cs
It's an experimental package. If you find any issues - please report on the Avalonia.Labs repository.