Is it possible to send Toast notification from console application?

前端 未结 3 2046
灰色年华
灰色年华 2020-12-08 05:12

Is it possible to send Toast notifications from console application using ToastNotificationManager ?

I know that it is possible to send Toast notifi

3条回答
  •  我在风中等你
    2020-12-08 05:47

    At first you need to declare that your program will be using winRT libraries:

    1. Right-click on your yourProject, select Unload Project
    2. Right-click on your yourProject(unavailable) and click Edit yourProject.csproj
    3. Add a new property group:8.0
    4. Reload project
    5. Add reference Windows from Windows > Core

    Now you need to add this code:

    using Windows.UI.Notifications;
    

    and you will be able to send notifications using this code:

    var toast = new ToastNotification(doc);
    ToastNotificationManager.CreateToastNotifier().Show(toast);
    

    Reference: How to call WinRT APIs in Windows 8 from C# Desktop Applications - WinRT Diagram

提交回复
热议问题