• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
手写的从前
博客园    首页    新随笔    联系   管理    订阅  订阅

Windows Phone 十三、吐司通知

弹出通知对话框

1     <Grid>
2         <Button 
3             Content="弹出通知"
4             Click="Button_Click"/>
5     </Grid>
1         private async void Button_Click(object sender, RoutedEventArgs e)
2         {
3             ////创建对话框对象
4             //MessageDialog dialog = new MessageDialog("吐司通知");
5             ////展示对话框
6             //await dialog.ShowAsync();
7             //少用,就像网页中不要使用alert一样
8             await new MessageDialog("弹出对话框").ShowAsync();
9         }

吐司通知

1     <Grid>
2         <Button 
3             Content="吐司通知"
4             Click="Button_Click_1"/>
5     </Grid>
 1         private async void Button_Click_1(object sender, RoutedEventArgs e)
 2         {
 3             //获取基本吐司模版
 4             var toastTmpl = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
 5             //填充模版占位符
 6             var textNode = toastTmpl.GetElementsByTagName("text").FirstOrDefault();
 7             if (textNode == null)
 8             {
 9                 await new Windows.UI.Popups.MessageDialog("shit").ShowAsync();
10                 return;
11             }
12             //设置innerText
13             textNode.InnerText = "Hello";
14             //创建一个吐司通知对象
15             var toastNotification = new ToastNotification(toastTmpl);
16             //展示吐司通知
17             //展示吐司通知需要一个展示对象
18             ToastNotificationManager.CreateToastNotifier().Show(toastNotification);
19         }

 

posted @ 2015-06-22 03:30  手写从前  阅读(235)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3