弹出通知对话框
<Grid>
<Button
Content="弹出通知"
Click="Button_Click"/>
</Grid>
private async void Button_Click(object sender, RoutedEventArgs e)
{
////创建对话框对象
//MessageDialog dialog = new MessageDialog("吐司通知");
////展示对话框
//await dialog.ShowAsync();
//少用,就像网页中不要使用alert一样
await new MessageDialog("弹出对话框").ShowAsync();
}
吐司通知
<Grid>
<Button
Content="吐司通知"
Click="Button_Click_1"/>
</Grid>
private async void Button_Click_1(object sender, RoutedEventArgs e)
{
//获取基本吐司模版
var toastTmpl = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
//填充模版占位符
var textNode = toastTmpl.GetElementsByTagName("text").FirstOrDefault();
if (textNode == null)
{
await new Windows.UI.Popups.MessageDialog("shit").ShowAsync();
return;
}
//设置innerText
textNode.InnerText = "Hello";
//创建一个吐司通知对象
var toastNotification = new ToastNotification(toastTmpl);
//展示吐司通知
//展示吐司通知需要一个展示对象
ToastNotificationManager.CreateToastNotifier().Show(toastNotification);
}