0

是否有可能在 WP7 中添加动态平铺,我在中心获取带有我的徽标的 PNG 文件并为其添加背景颜色?

它应该如下所示:

在此处输入图像描述

目前我像这样创建我的瓷砖:

private void addShortcut_Click(object sender, EventArgs e)
    {
        string Url = GlobalVariables.Uri;
        StandardTileData NewTileData = new StandardTileData
        {
            BackgroundImage = new Uri("img/red.jpg", UriKind.Relative),
            Title = "Energy "+GlobalVariables.Name,
            Count = 0,
            BackTitle = "Radion Energy",
            BackContent = "Hitmusic Only!",
            BackBackgroundImage = new Uri("img/test.jpg", UriKind.Relative)
        };
        try
        {
            // Create the Tile and pin it to Start. This will cause a navigation to Start and a deactivation of our application.
            ShellTile.Create(new Uri("/MainPage.xaml?stationName=" + stationName + "&tile=true&name=" + GlobalVariables.Name + "&url=" + Url, UriKind.Relative), NewTileData);
        }
        catch
        {
            MessageBox.Show("Channel-Tile exists already.");
        }
    }

因此,目前背景始终与 Phonestyle 本身具有相同的颜色。(我真的不明白为什么,因为 red.jpg 实际上是一个红色方块。:) 目前我没有徽标,所以它只是 blanc。

谢谢 :)

4

4 回答 4

1

您确定您的图片设置为“内容”吗?

于 2012-05-02T10:17:58.967 回答
1

我使用了 Ree7 Tile Toolkit,它允许您设置具有自定义背景颜色的瓷砖,源代码包括一个示例项目,它解释并演示了如何使用该工具包:-

http://wp7tiletoolkit.codeplex.com/

于 2012-05-02T10:21:32.817 回答
1
private const string FLICKR_LIVE_TILE = "/Shared/ShellContent/flickr_live_tile.jpg";
private const string FLTile = "/Shared/ShellContent/FLTile.jpg";

准备好WriteableBitmap你想要的任何来源

IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
                if (myIsolatedStorage.FileExists(FLTile))
                {
                    myIsolatedStorage.DeleteFile(FLTile);
                }
                using (IsolatedStorageFileStream iso = new IsolatedStorageFileStream(FLTile, FileMode.OpenOrCreate, IsolatedStorageFile.GetUserStoreForApplication()))
                {
                    WriteableBitmap1 .SaveJpeg(iso, 768, 200, 0, 100);
                    iso.Close();
                }
                if (myIsolatedStorage.FileExists(FLICKR_LIVE_TILE))
                {
                    myIsolatedStorage.DeleteFile(FLICKR_LIVE_TILE);
                }
                using (
             IsolatedStorageFileStream isoFileStream = new IsolatedStorageFileStream(FLICKR_LIVE_TILE, FileMode.OpenOrCreate,
             IsolatedStorageFile.GetUserStoreForApplication()))
                {
                    WriteableBitmap2 .SaveJpeg(isoFileStream, 336, 200, 0, 100);
                    isoFileStream.Close();
                }




                var shellTileData = new FlipTileData
                {
                    BackgroundImage = new Uri("isostore:" + FLICKR_LIVE_TILE, UriKind.RelativeOrAbsolute),
                    //BackContent = "Connectivity Slab",
                    SmallBackgroundImage = new Uri("isostore:" + FLICKR_LIVE_TILE, UriKind.RelativeOrAbsolute),
                    WideBackgroundImage = new Uri("isostore:" + FLTile, UriKind.RelativeOrAbsolute),
                    WideBackBackgroundImage = new Uri("isostore:" + FLTile, UriKind.RelativeOrAbsolute),
                    BackBackgroundImage = new Uri("isostore:" + FLICKR_LIVE_TILE, UriKind.RelativeOrAbsolute),
                };
                var tile = ShellTile.ActiveTiles.First();
                tile.Update(shellTileData);

它将有助于创建宽平铺图像和短平铺图像

于 2013-12-12T13:50:28.280 回答
0

如果它只显示一个 Square,那么您设置的图片 URI 不正确 :-)

编辑:图像也应该设置在“内容”上(已经提到过)

于 2012-05-02T10:36:37.270 回答