Source: http://www.bcmeng.com/tile/
Previous article to share the toast notification operation method, this article we will look at the Windows Phone 8.1 development of the magnet update. Magnets are a great highlight of Windows Phone Small dreams I also like very much. and updating the magnets is also a feature that many applications require. In fact, the method of updating the magnets and the toast notification is almost the same, because they are essentially an XML file.
Select a magnet Template:
There are many templates for magnets, so you can browse: http://msdn.microsoft.com/zh-cn/library/windows/apps/xaml/ Windows.ui.notifications.tiletemplatetype.aspx. This example selects a template:
tilesquare150x150peekimageandtext02. Concrete look at the end will have, one side is the picture, the back is the text. There are two parts of the text.
Its XML structure is as follows:
<tile> <visual version="2"> <binding template="tilesquare150x150peekimageandtext02"fallback="TileSquarePeekImageAndText02"> <image id="1"Src="Image1"alt="alt Text"/> <text id="1">text Field1(larger text) </text> <text id="2">text Field2</text> </binding> </visual></tile>
The code for selecting the template is as follows:
XmlDocument tilexml = tileupdatemanager.gettemplatecontent (tiletemplatetype.tilesquare150x150peekimageandtext02);
Provide text content for magnets
XmlNodeList tiletextattributes = Tilexml.getelementsbytagname ("text"); tiletextattributes[0" small Dream "; tiletextattributes[1" programming Small Dream welcome you ";
Providing images for magnets
XmlNodeList tileimageattributes = Tilexml.getelementsbytagname ("image"); ((XmlElement) tileimageattributes[0]). SetAttribute ("src""ms-appx:///assets/bcmeng.png");
To create a magnet:
New Tilenotification (Tilexml);
Set the magnet expiry time:
Tilenotification.expirationtime = DateTimeOffset.UtcNow.AddHours (in);
Send notifications to App tiles
Tileupdatemanager.createtileupdaterforapplication (). Update (tilenotification);
Windows Phone 8.1 Development: Magnets | Tile update