Generally, applications contain multiple sizes of magnetic tape, such as small magnetic tape (71 × 71), medium magnetic tape (150 × 150), and wide magnetic tape (310 × 150 ). The conventional method of tile update is to use an XML document to define the update content and then submit the update. For example:
<Tile>
<Visual version = "2">
<Binding template = "tilesquare150x150text02" fallback = "tilesquaretext02">
<Text id = "1"> </text>
<Text id = "2"> </text>
</Binding>
</Visual>
</Tile>
However, the size of the 150x150 tile is updated. We cannot determine the size of the tile that the user is using. It is possible that the user is using a 310x150 tile, then update the wide tile, for example:
<Tile>
<Visual version = "2">
<Binding template = "tilewide310x150image" fallback = "tilewideimage">
<Image id = "1" src = ""/>
</Binding>
</Visual>
</Tile>
The above method is divided into two updates. Is it possible to modify 150x150 and 310x150 at the same time after one update?
First, let's analyze it. the XML document defining the tile uses a tile element as the root node, indicating that it updates the tile instead of sending a toast notification. Then, the tile contains a single visual element, below the visual element is the binding element.
By the way, the skills are here. According to the instructions in the document,A visual element can contain multiple binding elements. Generally, a binding is a tile that describes a template..
Ah, have you thought about it? As you should have guessed, you just need to put a few more binding elements under the visual element, and then you can update multiple kinds of magnetic stickers at the same time.
For example, if I have an application that supports multiple sizes at the same time, I want to update both 150x150 and 310x150, so I just need to change the XML document to this.
<Tile> <visual version = "2"> <! -- Wide tile --> <binding template = "tilewide310x150blockandtext02" fallback = "tilewideblockandtext02"> <text id = "1"> text field 1 </text> <text id = "2"> text field 2 (Block text) </text> <text id = "3"> text field 3 (under block text) </text> </binding> <! -- Medium tile --> <binding template = "tilesquare150x150text02" fallback = "tilesquaretext02"> <text id = "1"> text field 1 (larger text) </text> <text id = "2"> text field 2 </text> </binding> </visual> </tile>
How? Let's try to see if it can be implemented.
Xmldocument docx = new xmldocument (); // create the root node xmlelement tile = docx. createelement ("tile"); docx. appendchild (tile); // create the visual element var visual = docx. createelement ("visual"); // sets the feature visual. setattribute ("version", "2"); tile. appendchild (visual); // Add the first binding element var binding = docx. createelement ("binding"); binding. setattribute ("template", "tilesquare150x150text02"); binding. setattribute ("fallback", "tilesquaretext02"); visual. appendchild (binding); // create two fields {var text1 = docx. createelement ("text"); binding. appendchild (text1); text1.setattribute ("ID", "1"); var textnode = docx.createtextnode(this.txt large. text); text1.appendchild (textnode); var text2 = docx. createelement ("text"); binding. appendchild (text2); text2.setattribute ("ID", "2"); textnode = docx. createtextnode (txtcontent. text); text2.appendchild (textnode);} // Add the second binding element binding = docx. createelement ("binding"); visual. appendchild (binding); binding. setattribute ("template", "tilewide310x150blockandtext02"); binding. setattribute ("fallback", "tilewideblockandtext02"); // Add three fields {var text1 = docx. createelement ("text"); binding. appendchild (text1); text1.setattribute ("ID", "1"); var textnode = docx.createtextnode(this.txt largeblock. text); text1.appendchild (textnode); var text2 = docx. createelement ("text"); binding. appendchild (text2); text2.setattribute ("ID", "2"); textnode = docx.createtextnode(this.txt underblock. text); text2.appendchild (textnode); var text3 = docx. createelement ("text"); binding. appendchild (text3); text3.setattribute ("ID", "3"); textnode = docx.createtextnode(this.txt normaltext. text); text3.appendchild (textnode);} // output to check whether the system is correct. diagnostics. debug. writeline (docx. getxml (); // 2. Create a notification to update tilenotification notifi = new tilenotification (docx); tileupdatemanager. createtileupdaterforapplication (). update (notifi );
Here I use Windows. data. XML. the APIs in the DOM namespace are used to create XML documents. If you think this is too complicated and confusing, you can directly splice the text, which may be difficult to make mistakes.
Okay. Check the effect.
How can this problem be solved.
Sample Code: http://files.cnblogs.com/tcjiaan/MultipTileUpdateApp.zip
Finally, let me talk about it again. No matter whether it's a tile or the XML document of toast notifications, never stick it to your back. You don't have to remember it. You just need to check the document when you use it, to use the template selectively, you do not need to use all the XML templates in an application. This is terrible, as long as you select the template you need.
[WP 8.1 Development] updates a variety of magnetic stickers at the same time