標籤:
彈出通知對話方塊
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 //設定innerText13 textNode.InnerText = "Hello";14 //建立一個多士通知對象15 var toastNotification = new ToastNotification(toastTmpl);16 //展示多士通知17 //展示多士通知需要一個展示對象18 ToastNotificationManager.CreateToastNotifier().Show(toastNotification);19 }
Windows Phone 十三、通知中樞