WP8更改应用程序平铺背景颜色

时间:2013-04-08 04:35:09

标签: colors background windows-phone-8 tiles

我一直在努力弄清楚如何更改与我的应用相关联的WP8磁贴的背景颜色。我尝试使用以下格式在TemplateIconic标记下的WMAppManifest.xml中设置BackgroundColor属性...

AARRGGBB

RRGGBB

这些似乎都不起作用,瓷砖始终是手机上设置的当前强调色。有人能指出我正确的方向吗?提前致谢。

2 个答案:

答案 0 :(得分:1)

您可以使用类似的方法设置应用程序磁贴的所有属性,包括BackgroundColor属性。

//REFERENCE: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207009(v=vs.105).aspx
// Set all the properties of the Application Tile.
private void SetApplicationTile()
{
    // Application Tile is always the first Tile, even if it is not pinned to Start.
    ShellTile TileToFind = ShellTile.ActiveTiles.First();

    // Application should always be found
    if (TileToFind != null)
    {
        IconicTileData TileData = new IconicTileData()
        {
            Title = "My App title",
            WideContent1 = "New Wide Content 1",
            WideContent2 = "New Wide Content 2",
            WideContent3 = "New Wide Content 3",
            //Count = 2,
            //BackgroundColor = Colors.Blue, 
            //BackgroundColor = new Color { A = 255, R = 200, G = 148, B = 255 },
            //BackgroundColor = Color.FromArgb(255, 200, 148, 55),
            //BackgroundColor = (Color)Application.Current.Resources["PhoneAccentColor"],
            BackgroundColor = HexToColor("#FF7A3B3F"),
            IconImage = new Uri("Assets/Tiles/IconicTileMediumLarge.png", UriKind.Relative),
            SmallIconImage = new Uri("Assets/Tiles/IconicTileSmall.png", UriKind.Relative),
        };

        // Update the Application Tile
        TileToFind.Update(TileData);
    }
}

public static Color HexToColor(string hex)
{
    return Color.FromArgb(
        Convert.ToByte(hex.Substring(1, 2), 16),
        Convert.ToByte(hex.Substring(3, 2), 16),
        Convert.ToByte(hex.Substring(5, 2), 16),
        Convert.ToByte(hex.Substring(7, 2), 16)
        );
}

IMPORTANT NOTE

  

如果未将BackgroundColor属性的A参数设置为255,则不会显示自定义背景颜色,而是显示默认主题颜色。

答案 1 :(得分:0)

据微软称,该值必须为#AARRGGBB。但我不能让它与任何价值一起工作。它似乎只是忽略它。 http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207009(v=vs.105).aspx

  

“如果BackgroundColor元素的颜色值不以#FF开头,   例如#FF524742,您的自定义背景颜色将不会显示和   将显示默认主题颜色。 “