[英]WP7 Mango: How do I delete a live tile?
我正在使用以下代碼在設備上創建實時磁貼:
ShellTile tile = ShellTile.ActiveTiles.FirstOrDefault();
StandardTileData newTileData = new StandardTileData
{
BackgroundImage = new Uri(string.Format("isostore:{0}", DefaultLiveTilePath), UriKind.Absolute),
Title = "Test"
};
tile.Update(newTileData);
稍后我想刪除實時圖塊圖像,並在固定時將其恢復為應用程序圖標。 這可能嗎?
根據這篇博客,您可以使用此代碼
public void DeleteExistingTile()
{
var foundTile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("DetailId=123"));
// If the Tile was found, then delete it.
if (foundTile != null)
{
foundTile.Delete();
}
}
每次應用程序啟動時,我都會將我的磁貼重置為正常時使用以下代碼:
private void ResetLiveTileToNormal()
{
ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault();
ShellTileData shellData = new StandardTileData
{
Title = "XXXXXXXX",
Count = 0,
BackContent = "",
BackTitle = "",
BackBackgroundImage = new Uri("", UriKind.Relative),
BackgroundImage = new Uri(@"/Images/LiveTiles/XXXXXX.png", UriKind.Relative)
};
TileToFind.Update(shellData);
}
ShellTile.ActiveTiles.FirstOrDefault();
已經過時了。
void clearTile() {
ShellTileData tileData = new StandardTileData
{
Title = "",
Count = 0,
BackContent = "",
BackTitle = "",
BackBackgroundImage = new Uri("", UriKind.Relative),
BackgroundImage = new Uri(@"/ApplicationIcon.png", UriKind.Relative)
};
IEnumerator<ShellTile> it = ShellTile.ActiveTiles.GetEnumerator();
it.MoveNext();
ShellTile tile = it.Current;
tile.Update(tileData);
}
基於研究並感謝robertftw
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.