I am trying to use the Iconic Tile Template to create a secondary live tile in my Windows Phone 8 app and I am getting an exception when creating the tile. The exception I am getting is:
A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.Phone.ni.dll
Additional information: initialData can be only of type StandardTileData.
the method I use to create the live tile is:
public void PinLock(Lock item)
{
Uri smallIcon = new Uri(item.IsLocked ? LockedIcon : UnlockedIcon, UriKind.Relative);
Uri largeIcon = new Uri(item.IsLocked ? LockedIcon : UnlockedIcon, UriKind.Relative);
var tileData = new IconicTileData
{
IconImage = largeIcon,
SmallIconImage = smallIcon,
Title = item.Name
};
string tileUri = "/MainPage.xaml?Action=LockDetails&LockId=" + item.Id;
ShellTile.Create(new Uri(tileUri, UriKind.Relative), tileData);
}
I have the live tile type set up in the WMAppManifest.xml like this:
<PrimaryToken TokenID="MyToken" TaskName="_default">
<TemplateIconic>
<SmallImageURI IsRelative="true" IsResource="false">Assets\lock-icon.png</SmallImageURI>
<Count>0</Count>
<IconImageURI IsRelative="true" IsResource="false">Assets\lock-icon.png</IconImageURI>
<Title>Locky</Title>
<Message>
</Message>
<BackgroundColor>
</BackgroundColor>
<HasLarge>false</HasLarge>
<LargeContent1>
</LargeContent1>
<LargeContent2>
</LargeContent2>
<LargeContent3>
</LargeContent3>
<DeviceLockImageURI IsRelative="true" IsResource="false">
</DeviceLockImageURI>
</TemplateIconic>
</PrimaryToken>
</Tokens>
I can't find any good examples of the correct way to do this and I can't find anybody else on the internet running into this exception message.
Other things I have tried:
- First creating the secondary template using StandardTemplateTileData and then when I update it try using IconicTileData. This throws an exception.
- First creating the secondary template using StandardTemplateTileData and then deleting it and replacing it with one using IconicTileData. This didn't work (throws the same exception as above)
Any help or good examples would be very much appreciated.