【问题标题】:How to change tile title with new Live Tile templates in Windows Phone 8.1 Universal app?如何在 Windows Phone 8.1 通用应用程序中使用新的动态磁贴模板更改磁贴标题?
【发布时间】:2015-09-19 22:17:32
【问题描述】:

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

在 WP8 中,您可以设置 TitleBackTitle,但在通用应用程序中似乎缺少这些参数。

知道如何做到这一点吗?我认为只能将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());

亲切的问候, 尼尔斯

【问题讨论】:

  • 我最终将标题渲染到图像中,同时将 Branding 变为 Branding.None。

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


【解决方案1】:

只需设置属性“branding”:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多