Implementing Toast Notifications in WPF
When to Use This Skill
Use this skill whenever the user needs to:
- Display temporary, non-intrusive notifications in WPF applications
- Show status messages (save successful, operation completed, errors)
- Implement notification alerts that auto-dismiss after a timeout
- Create native Windows OS notifications or custom in-app toasts
- Display severity-based messages (Info, Success, Warning, Error)
- Add interactive action buttons to notifications (Reply, Undo, OK)
- Show transient feedback that doesn't block user workflow
- Implement global or window-scoped notifications
Component Overview
SfToastNotification is a non-UI control (no XAML required) that displays toast notifications in WPF applications. It supports three display modes:
- Default Mode: Native Windows OS notifications (Windows 10+)
- Window Mode: In-app notifications constrained to window boundaries
- Screen Mode: Global overlay notifications across the screen
Key Characteristics:
- Code-only implementation (no XAML markup needed)
- Static API for showing/closing toasts
- Multiple severity levels with built-in visual styling
- Customizable animations, placement, and templates
- Interactive action buttons with callbacks
- Full template customization support
Documentation and Navigation Guide
Reference Files
- getting-started.md: Basic setup, NuGet installation, lifecycle management
- display-modes.md: Default/Window/Screen modes, bootstrapper setup, mode comparison
- severity-and-variants.md: Severity levels, visual variants, AccentBrush customization
- placement-and-animations.md: 8 placements, animation types, animation reference
- action-buttons.md: Action buttons, callbacks, CloseOnClick, custom templates
- template-customization.md: TitleTemplate, ContentTemplate, CloseButtonTemplate customization
Quick Start Example
Basic Information Toast
using System.Windows;
using Syncfusion.UI.Xaml.SfToastNotification;
namespace ToastDemo
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void ShowToast_Click(object sender, RoutedEventArgs e)
{
// Simple toast with title and message
SfToastNotification.Show(this, new ToastOptions
{
Mode = ToastMode.Screen,
Title = "Welcome",
Message = "Hello! This is your first toast notification."
});
}
}
}
Error Toast with Action Buttons
// Error toast with Retry and Dismiss actions
SfToastNotification.Show(this, new ToastOptions
{
Title = "Operation Failed",
Message = "Unable to save your changes. Please try again.",
Severity = ToastSeverity.Error,
Mode = ToastMode.Screen,
Actions = new List<ToastAction>
{
new ToastAction("Retry")
{
Callback = () => RetryOperation(),
CloseOnClick = true
},
new ToastAction("Dismiss")
{
CloseOnClick = true
}
}
});
Common Patterns
Native OS Notification
Initialize at startup via WindowsToastBootstrapper.Initialize(), then set Mode = ToastMode.Default.
Key Properties
- Title: Bold text at top (string)
- Message: Main body text (string)
- Mode: Display mode - Default (native OS), Window, or Screen
- Severity: Visual severity - None, Info, Success, Warning, Error
- Duration: Auto-close timeout (default: 6 seconds)
- PreventAutoClose: Disable auto-close (bool)
- Placement: Screen position (8 options: TopLeft, TopCenter, etc.)
- Variant: Visual variant - Text, Outlined, Filled
- AccentBrush: Custom color accent (Brush)
- ShowAnimationType: Show animation (FadeIn, Zoom, Slide, Flip, etc.)
- CloseAnimationType: Hide animation (FadeOut, etc.)
- Actions: Interactive action buttons (List)
- Id: Unique identifier for management (string)
1---2name: syncfusion-wpf-toast-notification3description: Guide for implementing Syncfusion WPF Toast Notification (SfToastNotification) control for displaying temporary notification messages. Use this skill when implementing toast notifications, pop-up alerts, status messages, or non-intrusive notifications in WPF applications. Covers showing success/error/warning messages, notification systems, and temporary UI feedback without blocking the main window.4---56# Implementing Toast Notifications in WPF78## When to Use This Skill910Use this skill whenever the user needs to:11- Display **temporary, non-intrusive notifications** in WPF applications12- Show **status messages** (save successful, operation completed, errors)13- Implement **notification alerts** that auto-dismiss after a timeout14- Create **native Windows OS notifications** or custom in-app toasts15- Display **severity-based messages** (Info, Success, Warning, Error)16- Add **interactive action buttons** to notifications (Reply, Undo, OK)17- Show **transient feedback** that doesn't block user workflow18- Implement **global or window-scoped notifications**1920## Component Overview2122**SfToastNotification** is a **non-UI control** (no XAML required) that displays toast notifications in WPF applications. It supports three display modes:23- **Default Mode:** Native Windows OS notifications (Windows 10+)24- **Window Mode:** In-app notifications constrained to window boundaries25- **Screen Mode:** Global overlay notifications across the screen2627**Key Characteristics:**28- Code-only implementation (no XAML markup needed)29- Static API for showing/closing toasts30- Multiple severity levels with built-in visual styling31- Customizable animations, placement, and templates32- Interactive action buttons with callbacks33- Full template customization support3435---3637## Documentation and Navigation Guide3839### Reference Files4041- **[getting-started.md](references/getting-started.md):** Basic setup, NuGet installation, lifecycle management42- **[display-modes.md](references/display-modes.md):** Default/Window/Screen modes, bootstrapper setup, mode comparison43- **[severity-and-variants.md](references/severity-and-variants.md):** Severity levels, visual variants, AccentBrush customization44- **[placement-and-animations.md](references/placement-and-animations.md):** 8 placements, animation types, animation reference45- **[action-buttons.md](references/action-buttons.md):** Action buttons, callbacks, CloseOnClick, custom templates46- **[template-customization.md](references/template-customization.md):** TitleTemplate, ContentTemplate, CloseButtonTemplate customization4748---4950## Quick Start Example5152### Basic Information Toast5354```csharp55using System.Windows;56using Syncfusion.UI.Xaml.SfToastNotification;5758namespace ToastDemo59{60 public partial class MainWindow : Window61 {62 public MainWindow()63 {64 InitializeComponent();65 }6667 private void ShowToast_Click(object sender, RoutedEventArgs e)68 {69 // Simple toast with title and message70 SfToastNotification.Show(this, new ToastOptions71 {72 Mode = ToastMode.Screen,73 Title = "Welcome",74 Message = "Hello! This is your first toast notification."75 });76 }77 }78}79```8081### Error Toast with Action Buttons8283```csharp84// Error toast with Retry and Dismiss actions85SfToastNotification.Show(this, new ToastOptions86{87 Title = "Operation Failed",88 Message = "Unable to save your changes. Please try again.",89 Severity = ToastSeverity.Error,90 Mode = ToastMode.Screen,91 Actions = new List<ToastAction>92 {93 new ToastAction("Retry")94 {95 Callback = () => RetryOperation(),96 CloseOnClick = true97 },98 new ToastAction("Dismiss")99 {100 CloseOnClick = true101 }102 }103});104```105106---107108## Common Patterns109110### Native OS Notification111112Initialize at startup via `WindowsToastBootstrapper.Initialize()`, then set `Mode = ToastMode.Default`.113114115116117118---119120## Key Properties121122- **Title:** Bold text at top (string)123- **Message:** Main body text (string)124- **Mode:** Display mode - Default (native OS), Window, or Screen125- **Severity:** Visual severity - None, Info, Success, Warning, Error126- **Duration:** Auto-close timeout (default: 6 seconds)127- **PreventAutoClose:** Disable auto-close (bool)128- **Placement:** Screen position (8 options: TopLeft, TopCenter, etc.)129- **Variant:** Visual variant - Text, Outlined, Filled130- **AccentBrush:** Custom color accent (Brush)131- **ShowAnimationType:** Show animation (FadeIn, Zoom, Slide, Flip, etc.)132- **CloseAnimationType:** Hide animation (FadeOut, etc.)133- **Actions:** Interactive action buttons (List<ToastAction>)134- **Id:** Unique identifier for management (string)135136---137138139140