WP 8.1更新方形和宽瓷砖 - 如何?

时间:2015-02-11 21:11:39

标签: c# live-tile win-phone-silverlight-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实例,并在同一个实例中完成所有操作..更糟糕的是,它只显示了宽广的瓷砖......

提前致谢。

此致 ben0bi

1 个答案:

答案 0 :(得分:1)

解决了它。根据MSDN,我们必须合并两个xml,以便它们出现在相同的" visual"标签

我是这样做的:

        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);