[英]Windows phone 8 array to set Color.FromArgb
I would like to set the background colour of the grid using the colours array. 我想使用colors数组设置网格的背景颜色。
int[] coloursArray = {255, 0, 100, 0};
GridBackgroundDARK.Background = new SolidColorBrush(Color.FromArgb(coloursArray.All));
The error is: 错误是:
No overload for method 'FromArgb' takes 1 arguments
方法'FromArgb'没有重载需要1个参数
Thank you in advance for any help :) 预先感谢您的任何帮助 :)
I don't think All
is what you're looking for here. 我不认为
All
都是你在这里寻找的。 If you want to use the values in the array, assuming they're in the correct order, you can do this: 如果要使用数组中的值,假设它们的顺序正确,则可以执行以下操作:
Color.FromArgb(coloursArray[0], coloursArray[1], coloursArray[2], coloursArray[3])
If you're going to do it often, you could create a method that does it for you 如果你经常这样做,你可以创建一个为你做的方法
public Color ColourFromArray(int[] cArray)
{
//add your error handling checks
//...
return Color.FromArgb(cArray[0], cArray[1], cArray[2], cArray[3])
}
你需要提供所有4个参数a,r,g,b。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.