I'm trying to create and update a tile for my windows phone application. But when I try to implement code below (which is works good for msdn sample), it throws "An exception of type 'System.ArgumentException' occurred in Microsoft.Phone.ni.dll but was not handled in user code
Additional information: Template type mismatch. You can only update the tile using the same template it was created with."
int newCount = 0;
// Application Tile is always the first Tile, even if it is not pinned to Start.
ShellTile TileToFind = ShellTile.ActiveTiles.First();
// Application should always be found
if (TileToFind != null)
{
// if Count was not entered, then assume a value of 0
if (textBoxCount.Text == "")
{
// A value of '0' means do not display the Count.
newCount = 0;
}
// otherwise get the numerical value for Count
else
{
newCount = int.Parse(textBoxCount.Text);
}
// set the properties to update for the Application Tile
// Empty strings for the text values and URIs will result in the property being cleared.
StandardTileData NewTileData = new StandardTileData
{
Title = textBoxTitle.Text,
BackgroundImage = new Uri(textBoxBackgroundImage.Text, UriKind.Relative),
Count = newCount,
BackTitle = textBoxBackTitle.Text,
BackBackgroundImage = new Uri(textBoxBackBackgroundImage.Text, UriKind.Relative),
BackContent = textBoxBackContent.Text
};
// Update the Application Tile
TileToFind.Update(NewTileData);
}
Exception is thrown by "TileToFind.Update(NewTileData);" line. I'm waiting for your suggestions. Thank you.
In Windows Phone 8, You can look at the WMAppManifest.xml
in your project. Tile Template can be TemplateFlip, TemplateCycle or TemplateIconic. Their Tile Data are:
FlipTileData(TemplateFlip), CycleTileData(TemplateCycle) and IconicTileData(TemplateIconic). Choose right TileData by the type of Tile Template in your WMAppManifest.xml.