Reputation: 324
I would like to set the background colour of the grid using the colours array.
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
Thank you in advance for any help :)
Upvotes: 1
Views: 271
Reputation: 69372
I don't think All
is what you're looking for here. 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])
}
Upvotes: 2