C# Windows 10 Toast通知视觉效果和操作不起作用
我正在编写一个c#控制台应用程序,它在Windows 10机器上的VS2017中发送toast通知。当我运行代码并且仅为通知定义了自适应文本内容时,它将正确运行并显示所需的文本。如果我添加动作,它将不再显示我定义的自适应文本(“标题”和“内容”),也没有执行上述动作的选项。如果我尝试添加其他视觉效果,例如徽标或图片,它们不会出现,但自适应文本不会受到影响C# Windows 10 Toast通知视觉效果和操作不起作用,c#,push-notification,windows-10,toast,visual-studio-2017,C#,Push Notification,Windows 10,Toast,Visual Studio 2017,我正在编写一个c#控制台应用程序,它在Windows 10机器上的VS2017中发送toast通知。当我运行代码并且仅为通知定义了自适应文本内容时,它将正确运行并显示所需的文本。如果我添加动作,它将不再显示我定义的自适应文本(“标题”和“内容”),也没有执行上述动作的选项。如果我尝试添加其他视觉效果,例如徽标或图片,它们不会出现,但自适应文本不会受到影响 string category = "Notifications"; string title = "New Test Notificati
string category = "Notifications";
string title = "New Test Notification!;
string content = "Testing push notifications!";
ToastContent toastContent = new ToastContent()
{
Visual = new ToastVisual()
{
BindingGeneric = new ToastBindingGeneric()
{
Children =
{
new AdaptiveText()
{
Text = title
},
new AdaptiveText()
{
Text = content
}
},
/*AppLogoOverride = new ToastGenericAppLogo()
{
Source = "https://unsplash.it/64?image=883",
HintCrop = ToastGenericAppLogoCrop.Circle
}*/
}
},
/*Actions = new ToastActionsCustom()
{
Buttons =
{
new ToastButton("check", "check")
{
ImageUri = "check.png"
},
new ToastButton("cancel", "cancel")
{
ImageUri = "cancel.png"
}
}
}*/
};
string toastXml = toastContent.GetContent();
XmlDocument doc = new XmlDocument();
doc.LoadXml(toastXml);
var toast = new ToastNotification(doc);
ToastNotificationManager.CreateToastNotifier(category).Show(toast);
运行上述代码时,无论是否使用第一个注释代码块,都会产生以下结果:
使用第二个注释代码块运行代码时的结果: