在Toast通知意外行为从桌面应用程序在Windows 10 [英] Unexpected behaviours in toast notification from desktop app in Windows 10
问题描述
我用桌面应用的Toast通知,因为Windows 8.1,但在Windows 10中的新的行动中心,我遇到了一些意外行为。
I used the toast notifications for desktop app since Windows 8.1 but with the new action center in Windows 10, I am experiencing some unexpected behaviours.
当用户做自认倒霉了烤面包,它只是消失而不去行动中心( ToastNotification.Dismissed
是 ToastDismissalReason.TimedOut
)。我不知道这是否涉及到的事实,我用它在Win32应用程序,但在Windows通用应用程序相同的敬酒去行动中心,当它超时。
When the user do nothing with the toast, it simply disappear without going to the action center (ToastNotification.Dismissed
is ToastDismissalReason.TimedOut
). I don't know if it related to the fact that I use it in a win32 app but the same toast in a Windows Universal App goes to the action center when it timed out.
有一点要注意的是,我还没有注册的的 AppUserModelID 我的Win32应用程序就像是在W8.1需要,这似乎不是强制性的了。我还是用注册ID测试,我有同样的popblem。
One thing to note is that I have not registered an AppUserModelID for my win32 app like it was needed in W8.1, it seems to not be mandatory anymore. I still tested with a registered id, and I had the same popblem.
所以,我怎样才能防止在行动中心不会当它超时敬酒?
So, how can i prevent the toast from not going in the action center when it timed out ?
下面是一个最低限度的代码(控制台应用程序),重现该问题:
Here is a minimalist code (console app) that reproduces the issue :
using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
namespace ToastDesktop
{
internal class Program
{
/// Add in the .csproj in the <PropertyGroup/> where <TargetFrameworkVersion/> is:
/// <TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion>
///
/// Reference to add :
/// - Windows.UI
/// - Windows.Data
private static void Main(string[] args)
{
string xml = $@"
<toast>
<visual>
<binding template='ToastGeneric'>
<text>Some title</text>
<text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</text>
</binding>
</visual>
</toast>";
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
ToastNotification toast = new ToastNotification(doc);
toast.Tag = "tag";
toast.Group = "group";
ToastNotificationManager.CreateToastNotifier("ToastDesktop").Show(toast);
}
}
}
感谢您的帮助。
Thanks for your help.
编辑:我张贴的 MSDN博客文章涵盖的主题,我得到确认,它应该留在行动中心时,超时,它可能是一个错误。
Edit : I posted this bug on the msdn blog post that cover the subject and I got the confirmation that it should remain in the action center when timed out and that it might be a bug.
推荐答案
Win32的应用程序需要建立一个COM服务器才能有敬酒坚持在操作中心:的 http://blogs.msdn.com/b/tiles_and_toasts/archive/2015/10/15/quickstart-handling-toast-activations-from-win32-apps-in-windows-10的.aspx
Win32 apps need to set up a COM server in order to have toasts persisted in Action Center: http://blogs.msdn.com/b/tiles_and_toasts/archive/2015/10/15/quickstart-handling-toast-activations-from-win32-apps-in-windows-10.aspx
这篇关于在Toast通知意外行为从桌面应用程序在Windows 10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!