开发者

whereshould i put this code for creating a tile

开发者 https://www.devze.com 2023-04-03 05:38 出处:网络
开发者_Python百科i want to setsecondry tile in my app but i don\'t know where i put codeof secondry tile because it show unhandled exception and myApp does not run it back

开发者_Python百科i want to set secondry tile in my app but i don't know where i put code of secondry tile because it show unhandled exception and my App does not run it back

var foundTile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("DetailId=123"));

if (foundTile == null)
{
    var secondaryTile = new StandardTileData
    {
        BackgroundImage = new Uri("Images/SecondaryTileFrontIcon.jpg", UriKind.Relative),
        Title = "hiiiiiiii",
        Count = null,
        BackTitle = "",
        BackContent = "byeeeee ",
        BackBackgroundImage = new Uri("Images/ApplicationTileIcon.jpg", UriKind.Relative)
    };

    ShellTile.Create(new Uri("/Views/DetailsPage.xaml?DetailId=123", UriKind.Relative), secondaryTile);
} 


Each tile is identified by the Uri supplied to ShellTile.Create. In your case, you're not creating a secondary tile, but checking if the same tile already exists, and if it's not, then you create it.

If you want more than one tile, you need to use different uri's for the ShellTile.Create call, typically with different query-string parameters/values.

And you obviously shouldn't make it dependant on the uri of completely unrelated tile.

0

精彩评论

暂无评论...
验证码 换一张
取 消