如何使用Mangopollo的IconicTileData更新我的应用程序的主要图块?

时间:2013-09-05 14:40:35

标签: windows-phone-7 windows-phone

我为Windows Phone 7/8编写了一个应用程序。我希望我的默认磁贴看起来像WP8,所以我以这种方式使用Mangopollo:

var tile = new IconicTileData
{
      Title = "WP Day",
      Count = 8,
      BackgroundColor = Colors.Transparent,
      IconImage = new Uri("/ApplicationIcon.png", UriKind.Relative),
      SmallIconImage = new Uri("/ApplicationIcon.png", UriKind.Relative),
      WideContent1 = "WP Developer Day",
      WideContent2 = "use Windows Phone 8 features",
      WideContent3 = "on Windows Phone 7 apps"
}.ToShellTileData();;

var tile2 = new StandardTileData
{
    Title = "E",
    Count = 9
};

ShellTile.ActiveTiles.FirstOrDefault().Update(tile);

但它没有效果。当我想用 tile 对象(IconicTileData)更新“first”tile时没有任何效果。但是当我使用 tile2 对象时,磁贴正在更新。有任何想法吗?

我在一些应用程序中看到了这些,例如TinyDO。

1 个答案:

答案 0 :(得分:0)

在修改链接后尝试了此代码:http://wp.qmatteoq.com/tag/mangopollo/

并且它有效..正是这条线可以解决这个问题:

Uri navigationUri = new Uri("/MainPage.xaml?Id=5", UriKind.Relative);
private void OnCreateWideTileClick(object sender, RoutedEventArgs e)
{
    if (true)
    {
        var tile = new IconicTileData
        {
            Title = "WP Day",
            Count = 8,
            BackgroundColor = Colors.Transparent,
            IconImage = new Uri("/Assets/Tiles/IconicTileMediumLarge.png", UriKind.Relative),
            SmallIconImage = new Uri("/Assets/Tiles/IconicTileSmall.png", UriKind.Relative),
            WideContent1 = "WP Developer Day",
            WideContent2 = "use Windows Phone 8 features",
            WideContent3 = "on Windows Phone 7 apps"
        }.ToShellTileData();

        ShellTileExt.Create(new Uri("/MainPage.xaml?Id=5", UriKind.Relative), tile, true);
    }
    else
    {
        MessageBox.Show("This is Windows Phone 7");
    }
}

private void OnUpdateTileClick(object sender, RoutedEventArgs e)
{
    if (Utils.IsWP8)
    {
        IconicTileData tile = new IconicTileData
        {
            WideContent1 = "This is the new content",
            WideContent2 = "The tile has been updated",
            WideContent3 = "with success"
        };

        Uri navigationUri = new Uri("/MainPage.xaml?Id=5", UriKind.Relative);
        ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri == navigationUri).Update(tile);
    }
}