Windows 10中桌面应用程序的Toast通知中出现意外行为

我从Windows 8.1开始使用桌面应用程序的Toast通知,但是在Windows 10中使用了新的操作中心,我遇到了一些意想不到的行为。

当用户不对吐司做任何事情时,它只是消失而不去动作中心( ToastNotification.DismissedToastDismissalReason.TimedOut )。 我不知道它是否与我在win32应用程序中使用它有关,但是Windows Universal App中的相同Toast在超时时会进入操作中心。

有一点需要注意的是,我没有为我的win32应用程序注册AppUserModelID ,就像在W8.1中需要它一样,它似乎不再是强制性的。 我仍然使用注册的身份证进行测试,并且我有相同的popblem。

那么,如何防止吐司在超时时不进入动作中心?

这是一个重现问题的极简主义代码(控制台应用程序):

 using Windows.Data.Xml.Dom; using Windows.UI.Notifications; namespace ToastDesktop { internal class Program { /// Add in the .csproj in the  where  is: /// 10.0.10240.0 /// /// Reference to add : /// - Windows.UI /// - Windows.Data private static void Main(string[] args) { string xml = $@"    Some title Lorem ipsum dolor sit amet, consectetur adipiscing elit.   "; XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); ToastNotification toast = new ToastNotification(doc); toast.Tag = "tag"; toast.Group = "group"; ToastNotificationManager.CreateToastNotifier("ToastDesktop").Show(toast); } } } 

谢谢你的帮助。

编辑:我在msdn博客文章中发布了这个错误,涵盖了主题,我得到了确认,它应该在超时时保留在操作中心并且可能是一个错误。

Win32应用程序需要设置一个COM服务器,以便在Action Center中保留Toast: http : //blogs.msdn.com/b/tiles_and_toasts/archive/2015/10/15/quickstart-handling-toast-activations-from -win32-应用function于Windows的10.aspx

COM方法的替代方法是为您的应用程序设置注册表项 。 在您的情况下,用ToastDesktop替换irssi