1
我正在尝试显示一个简单的吐司,它显示了我第一次部署该应用程序,但它不再显示。我没有改变任何部署之间的代码。这是基本空白的项目,除了在网主页这是唯一的代码吐司不显示
public MainPage()
{
this.InitializeComponent();
}
public static void Notification(string title, string content)
{
// Construct the visuals of the toast
ToastVisual visual = new ToastVisual()
{
TitleText = new ToastText()
{
Text = title
},
BodyTextLine1 = new ToastText()
{
Text = content,
},
};
ToastContent toastContent = new ToastContent()
{
Visual = visual,
};
// And create the toast notification
Windows.Data.Xml.Dom.XmlDocument doc = toastContent.GetXml();
var toast = new ToastNotification(toastContent.GetXml());
ToastNotificationManager.CreateToastNotifier().Show(toast);
}
private void buttonShowToast_Tapped(object sender, TappedRoutedEventArgs e)
{
Notification("a", "b");
}
NuGet包装: NotificationExtensions.Win10(版本:14332.0.2)
这很简单,因为它可以,为什么它不工作?我是否缺少某种权限?
您是否试图在按钮单击或其他事件中运行您的方法,而不是在构造函数中?这是整个代码 - 你已经将方法标记为* async *,但我没有看到* await *,也许你的方法在某处崩溃,因此它没有等待,你有无效,异常是吞没? – Romasz
另外 - 你用什么Nuget包* ToastVisual *?我已经尝试过[在MSDN上说](https://msdn.microsoft.com/en-US/windows/uwp/controls-and-patterns/tiles-and-notifications-adaptive-interactive-toasts)以及所有内容似乎工作。 – Romasz
我使用一个按钮和我使用的NuGet软件包更新了原始文章。仍然没有工作。 – vixez