Toast (toast) is a temporary notice on the top of the WP screen, he will be there for 7 seconds, can quickly locate the user's desired location (certainly by the developer set)
1. Create a Toast
Now, you'll need to have your app set up to support toast or even if you've written it, he's not working.
The direct selection in the application manifest is OK.
Then look at a sample code:
Public voidtoastnotification () {XmlDocument toastxml=toastnotificationmanager.gettemplatecontent (toasttemplatetype.toasttext01); XmlNodeList Elements= Toastxml.getelementsbytagname ("text"); elements[0]. AppendChild (Toastxml.createtextnode ("first Toast .")); Toastnotification Toast=Newtoastnotification (Toastxml); Toastnotificationmanager.createtoastnotifier (). Show (toast); }
Call where you need it:
Private void Button_Click (object sender, RoutedEventArgs e) { toastnotification (); }
Ok, you can experience toast!
The process of 2:toast
It's easy to see that creating a toast with a head takes 4 steps, 1-Creating a Toast notification template. 2-Add toast content. 3-Create a Toast notification object. 4-Popup Notification
3: Periodic notice
Some time we need is timed notification, the program can make the background run runtime, this time will be used scheduledtoastnotification, sample code:
Private voidToastNotification1 () {//scheduledtoastnotificationXmlDocument Toastxml =toastnotificationmanager.gettemplatecontent (toasttemplatetype.toasttext02); XmlNodeList Toastnodelist= Toastxml.getelementsbytagname ("text"); Toastnodelist.item (0). AppendChild (Toastxml.createtextnode ("Toast Title")); Toastnodelist.item (1). AppendChild (Toastxml.createtextnode ("Toast Content")); DateTime StartTime= DateTime.Now.AddSeconds ( -); Scheduledtoastnotification Recurringtoast=Newscheduledtoastnotification (Toastxml, startTime); Recurringtoast.id="Scheduled1"; Toastnotificationmanager.createtoastnotifier (). Addtoschedule (Recurringtoast); }
Note: To add to the constructor, ha
Toast for Windows Phone 8.1 development notes