2015-02-11 42 views
1

如何同時更新每個代碼的正方形和寬瓦片? 或者我怎樣才能確定,瓷磚類型是「加載」在開始屏幕上?WP 8.1更新廣場和寬瓦片 - 如何?

我有這樣的代碼:

private void JamesBond() 
{ 
     var tileXML = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text01); 
     var tileText = tileXML.GetElementsByTagName("text"); 
     (tileText[0] as XmlElement).InnerText = "First text"; 
     (tileText[1] as XmlElement).InnerText = "Second text"; 
     (tileText[2] as XmlElement).InnerText = "Third text"; 
     (tileText[3] as XmlElement).InnerText = "Last text"; 
     var tileNotification = new TileNotification(tileXML); 

     var tileXMLw = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text01); 
     var tileTextw = tileXMLw.GetElementsByTagName("text"); 
     (tileTextw[0] as XmlElement).InnerText = "Wide First text"; 
     (tileTextw[1] as XmlElement).InnerText = "Wide Second text"; 
     (tileTextw[2] as XmlElement).InnerText = "Wide Third text"; 
     (tileTextw[3] as XmlElement).InnerText = "Wide Last text"; 
     var tileNotificationW = new TileNotification(tileXMLw); 

     TileUpdateManager.CreateTileUpdaterForApplication().Clear(); 
     TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); 
     TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotificationW); 
    } 
} 

...和它做什麼,它更新了廣泛的瓦片。但是,如果它是方形瓷磚,那麼它有時更新它。大多數時候,它是空的。所以,它以某種方式起作用。但不正確....

任何人都可以幫我嗎?

PS:我也試圖讓TileUpdater實例,這樣做,所有在同一instance..that的更糟糕,那隻能說明廣瓦...

在此先感謝。

問候, ben0bi

回答

1

解決它。根據MSDN,我們必須合併這兩個XML,以便它們出現在相同的「可視」標籤下。

我做了這樣的:

 string xml="<tile>\n"; 
     xml += "<visual version=\"2\">\n"; 
     xml += " <binding template=\"TileSquare150x150Text01\" fallback=\"TileSquareText01\">\n"; 
     xml += "  <text id=\"1\">Row 0</text>\n"; 
     xml += "  <text id=\"2\">Row 1</text>\n"; 
     xml += "  <text id=\"3\">Row 2</text>\n"; 
     xml += "  <text id=\"4\">Row 3</text>\n"; 
     xml += " </binding>\n"; 
     xml += " <binding template=\"TileWide310x150Text01\" fallback=\"TileWideText01\">\n"; 
     xml += "  <text id=\"1\">Wide Row 0</text>\n"; 
     xml += "  <text id=\"2\">Wide Row 1</text>\n"; 
     xml += "  <text id=\"3\">Wide Row 2</text>\n"; 
     xml += "  <text id=\"4\">Wide Row 3</text>\n"; 
     xml += " </binding>\n"; 
     xml+="</visual>\n"; 
     xml +="</tile>"; 
     XmlDocument txml = new XmlDocument(); 
     txml.LoadXml(xml); 
     TileNotification tNotification = new TileNotification(txml); 

     TileUpdateManager.CreateTileUpdaterForApplication().Clear(); 
     TileUpdateManager.CreateTileUpdaterForApplication().Update(tNotification);