在win10系统上弹出toast和notification


Demo。 如果失效,请留言或来信索取376720513@qq.com

如果你想更灵活的控制弹出的通知,可以参考我这篇博客:【WPF】右下角弹出自定义通知样式(Notification)——简单教程


2018-03-09更新:
NND,今天发现微软更新了一篇又详细的文章,介绍的很好,简直手把手教你。
想看的请移步:Send a local toast notification from desktop C# apps

微软官方介绍:https://docs.microsoft.com/zh-cn/windows/apps/design/shell/tiles-and-notifications/send-local-toast?tabs=uwp

1.Quickstart: Handling toast activations from Win32 apps in Windows 10
2.github/desktop-toasts
3.Adaptive and interactive toast notifications
4.Send a local toast notification

出处:https://blog.csdn.net/catshitone/article/details/78522931

==========================================================================================

个人练习

我的开发环境是VS2017 ,使用framework4.6.1的环境,新建WinForm和wpf应用测试。

在项目的引用里,通过NuGet搜索并添加Microsoft.Toolkit.Uwp.Notifications的引用,我这里选择的版本是7.1.2,添加完成后,编译项目,会出现如下错误提示:

错误:  Must use PackageReference

解决方案:

需要在项目中的将packages.config迁移到PackageReference,具体操作如下:

Solution Explorer->右键单击References->“将packages.config迁移到PackageReference”

 再次编译,显示编译成功了。