Skip to content

Accurate toast notifications for WPF, visually similar to Windows 10 notifications.

License

Notifications You must be signed in to change notification settings

paulem/pixelmaniac.notifications

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo

Build status NuGet version NuGet downloads Pavel's Twitter

Notifications

Accurate toast notifications for WPF, visually similar to Windows 10 notifications.

See demo video

Notification screenshot Notification screenshot Notification screenshot

Features

  • Default toast notification template, visually similar to Windows 10
    • App identity
    • Attribution text
    • Vector & raster icon support
    • Choose between small 16px or large icon 48px
  • Unobtrusive, smooth animations
  • Easy to customize

Supported platforms

  • .NET Framework 4.5.2 +
  • .NET Core 3.1

Installation

Pixelmaniac.Notifications is available on NuGet.

Install using NuGet:

Install-Package Pixelmaniac.Notifications

Install using .NET CLI:

dotnet add package Pixelmaniac.Notifications

Usage

Show simple toast notification

var notificationManager = new NotificationManager();

notificationManager.Notify(
    message: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
    title: "Simple notification");

Use NotificationContent to override AppIdentity, set icons and etc.

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);

Show notification inside application window

  1. Add namespace:
xmlns:pxmc="https://github.com/paulem/pixelmaniac"
  1. Add NotificationArea within which notifications will be displayed:
<pxmc:NotificationArea MaxNotificationsCount="3" Position="BottomRight" />
  1. Show notification:
notificationManager.Options.InAppNotificationPlacement = true;

notificationManager.Notify(
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
    "Simple notification");

OnClick & OnClose actions

notificationManager.Notify(
    content,
    onClick: () => Console.WriteLine("Click"),
    onClose: () => Console.WriteLine("Closed"));

Caliburn.Micro MVVM support

Here is a fully working example of an app with Caliburn.Micro support.

  1. 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>
  1. 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));
  1. 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>

Thanks

https://github.com/Federerer

Languages

  • C# 100.0%