WP8.1 Study18: Live tile

Source: Internet
Author: User

First, preface

Live tiles are featured in WindowsPhone8.1 and Windows8.1, and some people like to hate it, but I think it's good to let users quickly know what's inside the app and entice users to open the app. Below to learn how to add live tile, actually quite simple.

Second, the tile template (tile ' s templates)

The tiles on the windows8.1 and the tiles on the windowsphone are roughly the same template, the MSDN documentation https://msdn.microsoft.com/en-us/library/windows/apps/ You can find the tile template you need on the hh761491.aspx?f=255&mspperror=-2147217396. The tiles are mainly peek,block,imagecollection. By looking at the documentation provided by MSDN, it is clear that the tile template is controlled by the content in XML format, with the following simple examples:

<Tile>  <Visualversion= "2">    <bindingTemplate= "Tilewide310x150peekimage02"fallback= "TileWidePeekImage02">      <ImageID= "1"src= "Image1.png"alt= "alt text"/>      <textID= "1">Text Field 1 (larger text)</text>      <textID= "2">Text Field 2</text>      <textID= "3">Text Field 3</text>      <textID= "4">Text Field 4</text>      <textID= "5">Text Field 5</text>    </binding>    </Visual></Tile>

Effect

Third, backstage code

Updating the app's tile is simple, and the C # code looks like this:

XmlDocument Tiledoc = new XmlDocument () tiledoc.loadxml ("<tile XML/>" ); Tilenotification mynewtile = new Tilenotification (Tiledoc); Tileupdater mytileupdater = Tileupdatemanager.createtileupdaterforapplication (); mytileupdater.update (myNewTile);

Iv. Specific Demo

  Public Static voidCreattiles () {stringTilesquare150x150image =@"Ms-appx:///assets/smalllogo.scale-240.png"; stringTilesquare310x150image =@"Ms-appx:///assets/widelogo.scale-240.png"; XmlDocument Tilexml=NewXmlDocument (); ////////////////////////////////////////////////////////            //Find all the available tile template formats at://      http://msdn.microsoft.com/en-us/library/windows/apps/Hh761491.aspx            stringTilestring ="<tile>"+"<visual version=\ "2\" >"+"<binding template=\ "tilesquare150x150peekimageandtext01\" fallback=\ "tilesquarepeekimageandtext01\" > "+"<image id=\ "1\" src=\ ""+ Tilesquare150x150image +"\ "alt=\" alt text\ "/>"+"<text id=\ "1\" >"+"MOV A #01H"+"</text>"+"<text id=\ "2\" >"+"assign the 01H to accumulator a"+"</text>"+"</binding>"+"<binding template=\ "tilewide310x150peekimage01\" fallback=\ "tilewidepeekimage01\" >"+"<image id=\ "1\" src=\ ""+ Tilesquare310x150image +"\ "alt=\" alt text\ "/>"+"<text id=\ "1\" >"+"MOV A #01H"+"</text>"+"<text id=\ "2\" >"+"assign the 01H to accumulator a"+"</text>"+"</binding>"+"</visual>"+"</tile>";            Tilexml.loadxml (tilestring); //New Tile NotificationTilenotification tile =Newtilenotification (Tilexml); //Update Tile NotificationsTileupdater Updatetiler =tileupdatemanager.createtileupdaterforapplication (); Updatetiler.enablenotificationqueue (false);        Updatetiler.update (tile); }

Whenever you want to update the tile information, you only need to call this method.

WP8.1 Study18: Live tile

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.