XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEToolBox

【WPF】XFE工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
using System.Windows;

namespace XFEToolBox.Client.Utilities;

public enum DesktopNotificationLevel
{
    Information,
    Warning,
    Error
}

public static class DesktopNotificationService
{
    public static void Show(
        string title,
        string message,
        DesktopNotificationLevel level = DesktopNotificationLevel.Information)
    {
        if (string.IsNullOrWhiteSpace(title) || Application.Current is not App app) return;
        if (app.Dispatcher.CheckAccess())
            app.ShowDesktopNotification(title, message, level);
        else
            app.Dispatcher.BeginInvoke(() => app.ShowDesktopNotification(title, message, level));
    }
}