我正在尝试初始化敬酒通知并将其发送给uwp,但无法识别内容名称,但始终建议使用其他内容名称。
我有一个XML文件和一个C#文件,它们是相同的Toast通知,当我要对其进行初始化并将其发送到我的应用程序时,我遇到了麻烦。
这是我的XML文件
<toast launch ="app-defined-string" scenario="Reminder">
<visual>
<binding template ="ToastGeneric">
<text>Reminder</text>
<text>Have you set up all of your arrangements for your trip to St. Petersburg yet? The closer you get to the date, the more expensive flights and excursions will cost!</text>
</binding>
</visual>
<actions>
<action content="Yes I've already made arrangements!" arguments="check" imageUri="check.png"/>
<action content="No, I haven't yet." arguments="cancel" imageUri="cancel.png"/>
</actions>
</toast>
这是我的C#文件,用于大致相同的通知
class ToastNotification
{
ToastContent content = new ToastContent()
{
Launch = "app-defined string",
Visual = new ToastVisual()
{
BindingGeneric = new ToastBindingGeneric()
{
Children =
{
new AdaptiveText()
{
Text = "Reminder"
},
new AdaptiveText()
{
Text = "Have you set up all of your arrangements for your trip to St. Petersburg yet? The closer you get to the date, the more expensive flights and excursions will cost!"
}
},
}
},
Actions = new ToastActionsCustom()
{
Buttons =
{
new ToastButton("Yes I have, thanks!", "thanks"),
new ToastButton("No I have not yet!", "later")
{
ActivationType = ToastActivationType.Foreground
}
}
}
};
}
当我尝试对其进行初始化时,我会在C#中尝试此操作:
XmlDocument xmlContent = content.GetXml();
ToastNotification notification = new ToastNotification(xmlContent);
ToastNotificationManager.CreateToastNotifier().Show(notification);
我遇到麻烦的问题是第一行,因为它无法识别内容。GetXml();部分;它会建议其他内容。