Customizing the Toast

Customizing a toast follows the same lines as customizing a badge or a tile template. You simply have to use the methods provided by the xmlDocument object to customize the XML To do this correctly you need to know the structure of the template. You can find this is in the documenation and the template we have been using is defined as:

We need to set an image src for the image tag and some text for the text tag. All of the discussions on how best to do this for the badge and tile template carry over here and if you want to know about them in detail read the ealier chapters.

To set a simple text message and an image stored on the web you would use something like:

A long duration toast stays on the screen for 25s compared to a short duration which stays for 7 seconds.

You can use the toastNotifier's Setting property to determine if the app is allowed to send toasts at the moment.

Using XML

An alternative to customizing the xmlDocument object after it has been constructed is to customize XML as text and use this to generate an xmlDocument object. This works in exactly the same way as for the badge and live tile examples. For example to create the same toast as above you would use: