带有WMS的Windows Phone 8.1 Silverlight应用程序中的空磁贴标题

本文关键字:标题 应用程序 Windows WMS Phone 带有 Silverlight | 更新日期: 2023-09-27 18:28:07

如何在带有WMS的Windows Phone 8.1 Silverlight应用程序中为磁贴设置空标题?

如果没有WMS,我只需要在WMAppManifest.xml中将DisplayName设置为空字符串,它就可以工作了。使用WMS,我不能再将DisplayName设置为Package.appxmanifest中的空字符串,因此应用程序标题始终显示在介质磁贴上,我不想显示在那里。

带有WMS的Windows Phone 8.1 Silverlight应用程序中的空磁贴标题

事实上,这并不相同。默认情况下,您将显示应用程序标题。但是,当您使用TileUpdateManager更新磁贴时,您可以删除标题。检查设置为"无"的"品牌"属性

var tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWidePeekImageAndText01);                
var tileImageAttributes = tileXml.GetElementsByTagName("image");
((XmlElement)tileImageAttributes[0]).SetAttribute("src", "ms-appdata:///local" + wideBackGroundUri.LocalPath);
var brandingAttribute = tileXml.GetElementsByTagName("binding");
((XmlElement)brandingAttribute[0]).SetAttribute("branding", "none");
tileXml.SelectSingleNode("//text[@id=1]").InnerText = wideBackContent;
TileNotification tileNotification = new TileNotification(tileXml);
TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);

就在new TileNotification之前,您可以添加以下代码。

  var squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquarePeekImageAndText04);
            var squareTileXmlAttributes = squareTileXml.GetElementsByTagName("image");
            ((XmlElement)squareTileXmlAttributes[0]).SetAttribute("src", "ms-appdata:///local" + backGroundUri.LocalPath);
            var brandingSquareAttribute = squareTileXml.GetElementsByTagName("binding");
            ((XmlElement)brandingSquareAttribute[0]).SetAttribute("branding", "none");
            squareTileXml.SelectSingleNode("//text[@id=1]").InnerText = backContent;
            IXmlNode node = tileXml.ImportNode(squareTileXml.GetElementsByTagName("binding").Item(0), true);
            tileXml.GetElementsByTagName("visual").Item(0).AppendChild(node);