Accurate toast notifications for WPF, visually similar to Windows 10 notifications.
- Default toast notification template, visually similar to Windows 10
- App identity
- Attribution text
- Vector & raster icon support
- Choose between small
16px
or large icon48px
- Unobtrusive, smooth animations
- Easy to customize
.NET Framework 4.5.2 +
.NET Core 3.1
Pixelmaniac.Notifications
is available on NuGet.
Install using NuGet:
Install-Package Pixelmaniac.Notifications
Install using .NET CLI:
dotnet add package Pixelmaniac.Notifications
var notificationManager = new NotificationManager();
notificationManager.Notify(
message: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
title: "Simple notification");
var notificationManager = new NotificationManager();
var content = new NotificationContent
{
Title = "Simple notification",
Message = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
AppIdentity = "App",
AttributionText = "Via PXMC",
VectorIcon = Application.Current.TryFindResource("[...]") as StreamGeometry,
UseLargeIcon = true
};
notificationManager.Notify(content);
- Add namespace:
xmlns:pxmc="https://github.com/paulem/pixelmaniac"
- Add
NotificationArea
within which notifications will be displayed:
<pxmc:NotificationArea MaxNotificationsCount="3" Position="BottomRight" />
- Show notification:
notificationManager.Options.InAppNotificationPlacement = true;
notificationManager.Notify(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"Simple notification");
notificationManager.Notify(
content,
onClick: () => Console.WriteLine("Click"),
onClose: () => Console.WriteLine("Closed"));
Here is a fully working example of an app with Caliburn.Micro support.
- Modify App.xaml:
xmlns:pxmc="https://github.com/paulem/pixelmaniac"
<Application.Resources>
[...]
<Style TargetType="{x:Type pxmc:Notification}">
<Style.Resources>
<DataTemplate DataType="{x:Type micro:PropertyChangedBase}">
<ContentControl cal:View.Model="{Binding}"/>
</DataTemplate>
</Style.Resources>
</Style>
</Application.Resources>
- Create a ViewModel and use it as a notification content:
var vm = new NotificationViewModel
{
Title = "Custom notification",
Message = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
};
_notificationManager.Notify(vm, expirationTime: TimeSpan.FromSeconds(30));
- You may use
controls:Notification.CloseOnClick
in your view:
<DockPanel LastChildFill="False">
<!--Using CloseOnClick attached property to close notification when button is pressed-->
<Button x:Name="Ok" Content="Ok" DockPanel.Dock="Right" controls:Notification.CloseOnClick="True"/>
<Button x:Name="Cancel" Content="Cancel" DockPanel.Dock="Right" Margin="0,0,8,0" controls:Notification.CloseOnClick="True"/>
</DockPanel>