Search code examples
c#windows-phone-7code-behindlive-tile

How do I avoid an error when trying to create multiple live tiles using the Windows Phone ShellTile API?


Starting off with the example here, I created an app to pin multiple tiles to the Start screen. When I pin the first tile, I have no issues. However, when I return to the app (via the app list or the back key), and click on a second image to pin the second tile, I get an InvalidOperationException.

Here is my simple code:

    private void Pin_Tile1(object sender, RoutedEventArgs e)
    {
        StandardTileData data1 = new StandardTileData
        {
            BackgroundImage = new Uri("Assets/tile1.png", UriKind.Relative),
            Title = "Tile 1",
            BackContent = "asdf"
        };

        ShellTile.Create(new Uri("/MainPage.xaml", UriKind.Relative), data1);
    }

    private void Pin_Tile2(object sender, RoutedEventArgs e)
    {
        StandardTileData data20 = new StandardTileData
        {
            BackgroundImage = new Uri("Assets/tile2.png", UriKind.Relative),
            Title = "Tile 2",
            BackContent = "fdsa"
        };
        ShellTile.Create(new Uri("/MainPage.xaml", UriKind.Relative), data2); 

    }

Can anyone tell me what is going on? Thanks for looking


Solution

  • From here, each live tile must point to a unique Uri, that is where I messed up.

    Full list of requirements is:

    • Each Live Tile must point to a unique URI location.
    • Each time that you create a secondary tile, the user will be taken to their home screen to view it. You can’t create more than one secondary tile at a time.
    • Limit the number of secondary live tiles allowed.