![](/img/trans.png)
[英]Windows Phone - update live tile from background agent with custom image
[英]Restoring a live tile to a static tile automatically after I remove its background agent
我的應用程序的主圖塊具有實時圖塊功能。 但是,如果我關閉實時磁貼功能,則返回到“開始”屏幕時,我的應用程序的主磁貼仍顯示實時磁貼的最后狀態。
我想知道如何在關閉活動磁貼功能后立即將應用程序的主磁貼恢復到靜態狀態? 目前,我需要調整圖塊大小或刪除/重新插入它才能獲得此效果。
這是我關閉實時磁貼時運行的代碼:
// Remove the Background Agent for the live tile.
ScheduledActionService.Remove("PeriodicTaskForLocation");
// Update tile.
RadFlipTileData extendedData = new RadFlipTileData()
{
WideVisualElement = null,
WideBackVisualElement = null,
IsTransparencySupported = true
};
ShellTile tile = ShellTile.ActiveTiles.First();
if (tile != null)
{
tile.Update(extendedData);
LiveTileHelper.UpdateTile(tile, extendedData);
}
這樣就可以了:
// Remove the Background Agent for the live tile.
RemoveAgent("PeriodicTaskForLocation");
// Delete tile.
ShellTile tile = ShellTile.ActiveTiles.First();
if (tile != null)
{
RadFlipTileData extendedData = new RadFlipTileData();
extendedData.IsTransparencySupported = true;
extendedData.WideBackgroundImage = new Uri("/Assets/Tiles/Icon.png", UriKind.Relative);
extendedData.WideBackVisualElement = null;
LiveTileHelper.UpdateTile(tile, extendedData);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.