how to change the background color of message box in WP8

隐身守侯 提交于 2019-12-08 09:45:50

问题


Actually, windows phone provide default message box with black background. I am already using custom message box using its toolkit. It has background property but I am unable to assign any value. It gives type casting error.

hope so someone will tell the right value, I alreay tried (0,0,0,0) / "grey" / colors.grey but same error

CustomMessageBox msgbox = new CustomMessageBox()
{
Caption = "Memory Race",
Message ="This is custom message box!",
LeftButtonContent = "OK",
Background = "what?"
};

回答1:


you can set backgroundcolor

Background =  new SolidColorBrush(Colors.Green);



回答2:


Background property is a color brush. You must do this:

*.Background = new SolidColorBrush(ConvertStringToColor("#0D0D0E"));

private Color ConvertStringToColor(String hex)
    {
        //remove the # at the front
        hex = hex.Replace("#", "");

        byte a = 255;
        byte r = 255;
        byte g = 255;
        byte b = 255;

        int start = 0;

        //handle ARGB strings (8 characters long)
        if (hex.Length == 8)
        {
            a = byte.Parse(hex.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
            start = 2;
        }

        //convert RGB characters to bytes
        r = byte.Parse(hex.Substring(start, 2), System.Globalization.NumberStyles.HexNumber);
        g = byte.Parse(hex.Substring(start + 2, 2), System.Globalization.NumberStyles.HexNumber);
        b = byte.Parse(hex.Substring(start + 4, 2), System.Globalization.NumberStyles.HexNumber);

        return Color.FromArgb(a, r, g, b);
    }



回答3:


See this link and stylize your CustomMessageBox



来源:https://stackoverflow.com/questions/20424662/how-to-change-the-background-color-of-message-box-in-wp8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!