实际上,Windows Phone提供黑色背景的默认消息框。我已经使用其工具包使用自定义消息框。它有背景属性但我无法分配任何值。它给出了类型转换错误。
希望所以有人会告诉正确的价值,我也试过(0,0,0,0)/“grey”/ colors.grey但同样的错误
CustomMessageBox msgbox = new CustomMessageBox()
{
Caption = "Memory Race",
Message ="This is custom message box!",
LeftButtonContent = "OK",
Background = "what?"
};
答案 0 :(得分:3)
您可以设置背景颜色
Background = new SolidColorBrush(Colors.Green);
答案 1 :(得分:0)
背景属性是一种颜色画笔。 你必须这样做:
*.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);
}
答案 2 :(得分:0)
请参阅此link并设置您的CustomMessageBox样式