[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Expand]Controls and Libraries
 [Collapse]Scaffolding Wizard
   Getting Started
  [Expand]Data Access Layer
   UI Generation
   [Collapse]Building Outlook-Inspired and Hybrid UI Applications
     Lesson 1 - Automatically Generate Outlook-Inspired and Hybrid User Interfaces From Entity Framework
     Lesson 2 - Show Splash Screen on the Start of the Application
     Lesson 3 - Customize Layout of the Collection Views
     Lesson 4 - Show Sparkline Charts in Grid Cells
     Lesson 5 - Use Cards Layout in Collection Views
     Lesson 6 - Use Master-detail Data Representation in Collection Views
     Lesson 7 - Using Conditional Formatting in Grid
     Lesson 8 - Add Advanced End-user Filtering Functionality to Applications
     Lesson 9 - Show Windows 8-style Toast Notifications
     Lesson 10 - Add Windows 7-style Jump List to the Application
     Lesson 11 - Add Custom Actions to Application's Taskbar Thumbnail
   [Expand]Building Office-Inspired Applications
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Lesson 9 - Show Windows 8-style Toast Notifications

Windows 8 style toast notifications allow you to notify the user about some events even if the application is not currently active. The DevExpress NotificationService enables you to show native Windows 8 notifications in a MVVM style and even simulate them in earlier versions of Windows.

In this lesson, you will learn how to notify the user when a new task is assigned to an employee.

Expanded Step 1 - Adding necessary Services to the View

To use the INotificationService interface from a view model, register the corresponding service interface implementation in the corresponding view.

Open the DevAVDbView.xaml file in the designer and invoke the Document Outline window (VIEW | Other Windows | Document Outline). In the Document Outline window, select the root UserControl, open its smart tag and select the MVVM Behaviors and Services tab. Click the Add Service item and choose the NotificationService from the menu.

Select the added service and set its PredefinedNotificationDuration property to Long, the PredefinedNotificationTemplate property to ShortHeaderAndLongText, UseWin8NotificationsIfAvailable to False.

You also need the IDocumentManagerService to show information about a new task. Use the Add Service item to add the WindowedDocumentUIService and name it SingleObjectDocumentManagerService.

Expanded Step 2 - Using INotificationService from the view model

The idea is to track when a new task is added and store its Id.

Every 3 seconds a request for the last Id is being called and if it has been changed, a notification is shown. If a customer clicks the notification, the SingleObjectDocumentManagerService is used to show information about the new task.

It is necessary to track whether a new task has been created in the same instance of the application.

This approach is not perfect. For example, if more than one task is created between two Id requests, only one notification will be shown. However, this behavior is enough for demonstration purposes.

Expanded Step 3 - Testing the Functionality

Run two instances of the application and double-click any employee in the first instance. In the employee editing form, scroll to the Assigned Tasks grid and click the New action.

In the new task editing form, fill the Subject and Description fields and save the task.

Within 3 seconds, a toast notification will appear in the upper right corner of the screen.

Click the notification to show the task editing form in the second instance of the application.

Applications that contain the result of this lesson are available here: DevExpress.OutlookInspiredApp and DevExpress.HybridApp.

Expanded See Also

Is this topic helpful?​​​​​​​