C#Windows 10 Toast通知
我试图在计时器超时后显示toast通知。 通知在我的一台电脑上有效,但另一台电脑不会显示它。当我调试它时,我没有收到任何错误。 我还尝试在设置>通知中设置一些内容,但在允许/不允许显示通知的应用程序列表中,我看不到我的应用程序 这是我的通知类:C#Windows 10 Toast通知,c#,windows,push-notification,toast,C#,Windows,Push Notification,Toast,我试图在计时器超时后显示toast通知。 通知在我的一台电脑上有效,但另一台电脑不会显示它。当我调试它时,我没有收到任何错误。 我还尝试在设置>通知中设置一些内容,但在允许/不允许显示通知的应用程序列表中,我看不到我的应用程序 这是我的通知类: class NewToastNotification { public NewToastNotification(string text) { string Toast = String.Forma
class NewToastNotification
{
public NewToastNotification(string text)
{
string Toast = String.Format("<toast>"+
"<visual>+" +
"<binding template=\"ToastImageAndText04\">" +
"<text id = \"1\" >Toast Test </text>+" +
"<text id = \"2\" >{0}</text>+" +
"<text id = \"2\" >{1}</text>+" +
"</binding>+" +
"</visual>+" +
"</toast>", text, DateTime.Now);
var tileXml = new Windows.Data.Xml.Dom.XmlDocument();
tileXml.LoadXml(Toast);
var toast = new ToastNotification(tileXml);
ToastNotificationManager.CreateToastNotifier("1").Show(toast);
}
}
class NewToastNotification
{
公共NewOastNotification(字符串文本)
{
string Toast=string.Format(“”)+
"+" +
"" +
“Toast测试+”+
"{0}+" +
"{1}+" +
"+" +
"+" +
“”,文本,日期时间。现在);
var tileXml=new Windows.Data.Xml.Dom.XmlDocument();
LoadXml(Toast);
var toast=新toast通知(tileXml);
ToastNotificationManager.CreateToastNotifier(“1”).Show(toast);
}
}
使用
而不是
ToastNotificationManager.CreateToastNotifier("1").Show(toast);
我怀疑字符串中结束标记后的加号是否正确。另外,你确定有两个相同Id的文本标记是正确的吗?我想你是对的,我更改了它,但它也不起作用。应用程序运行的电脑使用的是Windows 10 Pro,另一台是Windows 10 Home。关于通知,可能有什么不同吗?
ToastNotificationManager.CreateToastNotifier("1").Show(toast);