0

我正在为 Windows 手机开发一个购物应用程序。

如果我手动固定磁贴,我可以通过我的代码更新磁贴。

这是我更新磁贴的代码

 ShellTile TileToFind = ShellTile.ActiveTiles.First();

            StandardTileData NewTileData = new StandardTileData
            {
                BackgroundImage = new Uri(offer_mobile_image[0], UriKind.RelativeOrAbsolute),
                Count = NotificationCount,
                BackTitle = location_area,
                BackContent = offer_title,
            };


            TileToFind.Update(NewTileData);

如果我通过代码动态创建动态磁贴,则无法更新磁贴

这是我用来创建动态磁贴的代码

private void PinToStart()
    {
        StandardTileData standardTileData = new StandardTileData();
        standardTileData.BackgroundImage = new Uri(@"/ApplicationTile.png", UriKind.RelativeOrAbsolute);
        standardTileData.Title = "MyApplication";
        standardTileData.BackTitle = "this is my app";
        standardTileData.BackContent = "this is very good app";

        // Check if the application tile has already been defined - this is a tile that links to the app main page
        ShellTile tiletopin = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("MainPage.xaml"));
        if (tiletopin == null)
        {
            //Create ShellTile linking to main page of app
            ShellTile.Create(new Uri("/MainPage.xaml", UriKind.Relative), standardTileData);
        }
        else
        {
            MessageBox.Show("Application is already Pinned");
        }
    }

谁能帮我更新动态创建的图块。谢谢你。

4

1 回答 1

0

您的问题是 - 您正在尝试更新主磁贴,但您创建了辅助磁贴。主图块始终是第一个图块。

如果您UpdateTile()像这样更新您的方法:

ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(
              x => x.NavigationUri.ToString().Contains("MainPage.xaml"));

通过代码创建的图块将被更新。

于 2013-11-01T09:15:40.563 回答