Pergunta

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?"
};
Foi útil?

Solução

you can set backgroundcolor

Background =  new SolidColorBrush(Colors.Green);

Outras dicas

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);
    }

See this link and stylize your CustomMessageBox

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top