我正在尝试为我的Windows手机应用程序创建和更新磁贴。但是当我尝试在下面实现代码时(这对msdn示例有效),它会抛出"类型' System.ArgumentException'的异常。发生在Microsoft.Phone.ni.dll但未在用户代码中处理
其他信息:模板类型不匹配。您只能使用创建的相同模板更新磁贴。"
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);
}
" TileToFind.Update(NewTileData);"抛出异常。线。我在等你的建议。谢谢。
答案 0 :(得分:1)
在Windows Phone 8中,您可以查看项目中的WMAppManifest.xml
。平铺模板可以是TemplateFlip,TemplateCycle或TemplateIconic。他们的瓷砖数据是:
FlipTileData (TemplateFlip), CycleTileData (TemplateCycle)和 IconicTileData (TemplateIconic)。 根据WMAppManifest.xml中的Tile Template类型选择正确的TileData。