WindowsToastApi 1.0.1

dotnet add package WindowsToastApi --version 1.0.1
                    
NuGet\Install-Package WindowsToastApi -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WindowsToastApi" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WindowsToastApi" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="WindowsToastApi" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add WindowsToastApi --version 1.0.1
                    
#r "nuget: WindowsToastApi, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package WindowsToastApi@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=WindowsToastApi&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=WindowsToastApi&version=1.0.1
                    
Install as a Cake Tool

WindowsToastApi

Simple, Win32-friendly Windows Toast Notification API for .NET apps (Console, WPF, WinForms) on Windows 10/11.
Built on top of CommunityToolkit.WinUI.Notifications.


✨ Features

  • ✅ Show toast notifications from Console, WinForms, WPF (Win32) apps
  • ✅ One-line Toast.Info/Success/Warning/Error presets
  • ✅ Custom buttons, payload, hero images, app logos
  • ✅ Activation callback with arguments and user input
  • ✅ Handles AppUserModelID + Start Menu shortcut automatically
  • ✅ Includes XML docs, SourceLink, symbols (.snupkg)

📦 Install

dotnet add package WindowsToastApi

Requires net8.0-windows10.0.19041.0 or higher.


🚀 Quick Start

using WindowsToastApi;

// 1. Initialize once at app startup
Toast.Initialize(
    appId: "YourCompany.YourApp",
    displayName: "Your App",
    iconPath: null);

// 2. Optional: subscribe to activation callback
Toast.Activated += args =>
{
    Console.WriteLine($"Activated: {args.Arguments}");
    foreach (var kv in args.Payload)
        Console.WriteLine($"{kv.Key}={kv.Value}");
};

// 3. Show presets
Toast.Info("Hello", "This is an info toast");
Toast.Success("Backup complete", "All files synced");
Toast.Warning("High CPU", "Process using 92%");
Toast.Error("Service crashed", "EventLogWatcher stopped");

// 4. Show toast with buttons & payload
Toast.Show("Deploy ready", "Promote to production?",
    new ToastOptions
    {
        PrimaryButton = ("Deploy now", "deploy"),
        SecondaryButton = ("Later", "later"),
        Payload = new Dictionary<string,string> { ["pipelineId"] = "a1b2c3" },
        Duration = ToastDuration.Long
    });

🔧 API Overview

Toast.Initialize(string appId, string displayName, string? iconPath = null)

  • Must be called once before showing toasts.
  • Creates a Start Menu shortcut with the given AppUserModelID.

Toast.Show(string title, string message, ToastOptions? options = null)

  • Show a custom toast with text, optional images, buttons, payload.

Presets

  • Toast.Info(string title, string message, ToastOptions? options = null)
  • Toast.Success(...)
  • Toast.Warning(...)
  • Toast.Error(...)

Activation

Toast.Activated += args =>
{
    Console.WriteLine(args.Arguments);
    foreach (var kv in args.Payload)
        Console.WriteLine($"{kv.Key}={kv.Value}");
};

ToastOptions

  • HeroImagePath → large hero image
  • AppLogoOverridePath → circle app logo
  • Silent → mute sound
  • DurationShort or Long
  • ScenarioDefault, Alarm, Reminder, IncomingCall
  • PrimaryButton / SecondaryButton(content, arguments)
  • Payload → dictionary returned on activation

📸 Screenshot (Example)

(insert your screenshot of a sample toast here)


⚠️ Notes & Limitations

  • Win32 apps require a Start Menu shortcut with AppUserModelID → handled by Toast.Initialize.
  • Works only in interactive user sessions (not background Windows Services).
  • Images/icons must be absolute file paths or file:/// URIs.
  • Windows may throttle notifications if spamming.

🛠 Development

Clone and build locally:

git clone https://github.com/BenSowieja/WindowsToastApi.git
cd WindowsToastApi
dotnet build -c Release
dotnet pack src/WindowsToastApi/WindowsToastApi.csproj -c Release -o out

📄 License

MIT © 2025 Ben Sowieja

Product Compatible and additional computed target framework versions.
.NET net8.0-windows10.0.19041 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 118 9/10/2025
1.0.0 119 9/10/2025