C# Windows 10中桌面应用的toast通知中出现意外行为
我从Windows 8.1开始使用桌面应用程序的toast notifications,但在Windows 10中使用新的action center后,我遇到了一些意想不到的行为 当用户对toast不做任何操作时,它只会消失而不去操作中心(C# Windows 10中桌面应用的toast通知中出现意外行为,c#,notifications,toast,windows-10,C#,Notifications,Toast,Windows 10,我从Windows 8.1开始使用桌面应用程序的toast notifications,但在Windows 10中使用新的action center后,我遇到了一些意想不到的行为 当用户对toast不做任何操作时,它只会消失而不去操作中心(ToastNotification.DisabledisToastDismissalReason.TimedOut)。我不知道这是否与我在win32应用程序中使用它有关,但在Windows Universal应用程序中,当它超时时,同样的祝酒词会传到动作中心
ToastNotification.Disabled
isToastDismissalReason.TimedOut
)。我不知道这是否与我在win32应用程序中使用它有关,但在Windows Universal应用程序中,当它超时时,同样的祝酒词会传到动作中心
需要注意的一点是,我还没有像W8.1中那样为我的win32应用程序注册一个,它似乎不再是强制性的。我仍然使用注册id进行测试,我也有同样的问题
那么,我怎样才能防止烤面包片超时时不进入行动中心呢
下面是一个最低限度的代码(控制台应用程序),它再现了这个问题:
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);
}
}
}
使用Windows.Data.Xml.Dom;
使用Windows.UI.Notifications;
名称空间到桌面
{
内部课程计划
{
///在where is中添加.csproj:
/// 10.0.10240.0
///
///参考添加:
///-Windows.UI
///-Windows.Data
私有静态void Main(字符串[]args)
{
字符串xml=$@”
一些头衔
Lorem ipsum dolor sit amet,是一位杰出的献身者。
";
XmlDocument doc=新的XmlDocument();
doc.LoadXml(xml);
ToastNotification toast=新ToastNotification(doc);
toast.Tag=“Tag”;
toast.Group=“Group”;
ToastNotificationManager.CreateToastNotifier(“ToastDesktop”).Show(toast);
}
}
}
谢谢你的帮助
编辑:我在该主题的封面上发布了此错误,我得到确认,当超时时,它应该保留在action center中,并且它可能是一个错误。Win32应用程序需要设置一个COM服务器,以便在action center中持久保存祝酒词:COM方法的另一个替代方法是为您的应用程序设置。在您的情况下,将
irssi
替换为ToastDesktop