Giter Site home page Giter Site logo

notifications.wpf's Introduction

Notifications.Wpf

WPF toast notifications.

Demo

Installation:

Install-Package Notifications.Wpf

Usage:

Notification over the taskbar:

var notificationManager = new NotificationManager();

notificationManager.Show(new NotificationContent
           {
               Title = "Sample notification",
               Message = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
               Type = NotificationType.Information
           });

Notification inside application window:

  • Adding namespace:
xmlns:notifications="clr-namespace:Notifications.Wpf.Controls;assembly=Notifications.Wpf"
  • Adding new NotificationArea:
<notifications:NotificationArea x:Name="WindowArea" Position="TopLeft" MaxItems="3"/>
  • Displaying notification:
notificationManager.Show(
                new NotificationContent {Title = "Notification", Message = "Notification in window!"},
                areaName: "WindowArea");

Simple text with OnClick & OnClose actions:

notificationManager.Show("String notification", onClick: () => Console.WriteLine("Click"),
               onClose: () => Console.WriteLine("Closed!"));

Caliburn.Micro MVVM support:

  • App.xaml:
xmlns:controls="clr-namespace:Notifications.Wpf.Controls;assembly=Notifications.Wpf"

<Application.Resources>
    [...]
    <Style TargetType="controls:Notification">
        <Style.Resources>
            <DataTemplate DataType="{x:Type micro:PropertyChangedBase}">
                <ContentControl cal:View.Model="{Binding}"/>
            </DataTemplate>
        </Style.Resources>
    </Style>
</Application.Resources>
  • ShellViewModel:
var content = new NotificationViewModel(_manager)
{
    Title = "Custom notification.",
    Message = "Click on buttons!"
};

_manager.Show(content, expirationTime: TimeSpan.FromSeconds(30));
  • NotificationView:
<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>
  • Result:

Demo

notifications.wpf's People

Contributors

camiteca avatar federerer avatar hidend avatar

Watchers

 avatar

Forkers

codelab-lite

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.