Toast of Windows Phone 8.1 development notes

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.