-1

我正在为 WP8 开发一个应用程序。我想知道如何通过单击用户创建的应用程序列表或主磁贴来确定我的应用程序是否进入前台。我想知道有多少用户创建了主磁贴.

4

2 回答 2

1

You can add a navigation parameter to your secondary tile like this :

        string tileParameter = "Param=myParameter"; 
        ShellTile tile = CheckIfTileExist(tileParameter); 
        if (tile == null) 
        { 
            StandardTileData secondaryTile = new StandardTileData 
            { 
                Title = tileParameter, 
                BackgroundImage = new Uri("Background-Secondary.png", UriKind.Relative), 
                Count = 2, 
                BackContent = "Secondary Tile Test" 

            }; 
            ShellTile.Create(new Uri("/MainPage.xaml?" + tileParameter, UriKind.Relative), secondaryTile); 
        } 

and then, in your MainPage's OnNavigatedTo event, you can get this parameter with something like this:

        if (this.NavigationContext.QueryString.ContainsKey("Param")) 
        { 
            string param = this.NavigationContext.QueryString["Param"];//Get "Param" this query string. 
            //Do whatever you want with this parameter
        } 
于 2013-04-25T14:38:23.383 回答
0

您的 URI 中有查询字符串吗?如果是这样,您可以检查 NavigationContext.QueryString 并查看是否设置了辅助磁贴中使用的参数。

于 2013-04-25T14:36:11.907 回答