我正在为 Windows 手机开发一个购物应用程序。
如果我手动固定磁贴,我可以通过我的代码更新磁贴。
这是我更新磁贴的代码
ShellTile TileToFind = ShellTile.ActiveTiles.First();
StandardTileData NewTileData = new StandardTileData
{
BackgroundImage = new Uri(offer_mobile_image[0], UriKind.RelativeOrAbsolute),
Count = NotificationCount,
BackTitle = location_area,
BackContent = offer_title,
};
TileToFind.Update(NewTileData);
如果我通过代码动态创建动态磁贴,则无法更新磁贴
这是我用来创建动态磁贴的代码
private void PinToStart()
{
StandardTileData standardTileData = new StandardTileData();
standardTileData.BackgroundImage = new Uri(@"/ApplicationTile.png", UriKind.RelativeOrAbsolute);
standardTileData.Title = "MyApplication";
standardTileData.BackTitle = "this is my app";
standardTileData.BackContent = "this is very good app";
// Check if the application tile has already been defined - this is a tile that links to the app main page
ShellTile tiletopin = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("MainPage.xaml"));
if (tiletopin == null)
{
//Create ShellTile linking to main page of app
ShellTile.Create(new Uri("/MainPage.xaml", UriKind.Relative), standardTileData);
}
else
{
MessageBox.Show("Application is already Pinned");
}
}
谁能帮我更新动态创建的图块。谢谢你。