如何使用Windows Phone 8.1 Universal app中的新Live Tile模板更改磁贴标题?

时间:2014-09-06 06:15:07

标签: c# live-tile win-universal-app

现在,我正在为我的应用生成自定义图块。但是我想要动态更改磁贴的标题(例如,我可以显示当前位置)。

在WP8中,您可以设置TitleBackTitle,但在Universal Apps中似乎缺少这些参数。

有关如何做到这一点的任何想法?我认为只能将Branding设置为BadgeIcon或应用标题?我想将(Front)Title设置为一个字符串,然后将标题设置为空。

/// RENDERING THE TILES
string WideFrontTile = await RenderWideFront(WeatherData);
string MediumFrontTile = await RenderMediumFront(WeatherData);
string WideBackTile = await RenderWideBack(WeatherData);
string MediumBackTile = await RenderMediumBack(WeatherData);

// FRONT TILES
ITileWide310x150Image WideFrontContent = TileContentFactory.CreateTileWide310x150Image();
WideFrontContent.Image.Src = WideFrontTile;
ITileSquare150x150Image MediumFrontContent = TileContentFactory.CreateTileSquare150x150Image();
MediumFrontContent.Image.Src = MediumFrontTile;
WideFrontContent.Square150x150Content = MediumFrontContent;

// BACK TILES
ITileWide310x150Image WideBackContent = TileContentFactory.CreateTileWide310x150Image();
WideBackContent.Image.Src = WideBackTile;
ITileSquare150x150Image MediumBackContent = TileContentFactory.CreateTileSquare150x150Image();
MediumBackContent.Image.Src = MediumBackTile;
WideBackContent.Square150x150Content = MediumBackContent;


// Clear all tiles, push new tiles
TileUpdateManager.CreateTileUpdaterForApplication().Clear();
TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
TileUpdateManager.CreateTileUpdaterForApplication().Update(WideBackContent.CreateNotification());
TileUpdateManager.CreateTileUpdaterForApplication().Update(WideFrontContent.CreateNotification());

亲切的问候, 尼尔斯

1 个答案:

答案 0 :(得分:1)

只需设置属性"品牌":

    var TileMgr = TileUpdateManager.CreateTileUpdaterForApplication();
    TileMgr.Clear();
    var tileTemplate = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Image);

    // Quitamos el nombre de la app.
    XmlElement tmp = tileTemplate.GetElementsByTagName("visual")[0] as XmlElement;
    tmp.SetAttribute("branding", "none");
    var notification = new TileNotification(tileTemplate);
    TileMgr.Update(notification);