Side code, however, we do not have the same ease of choice. This is because the Color class has only a default constructor without parameters. This means that simply wanting to use it, then we must make use of the property A, R, G and B.
Code:
Color c = new Color ();
cA = 255; cR = 0; cG = 0, cB = 0;
SolidColorBrush brush = new SolidColorBrush (c);
As you can see is quite inconvenient. Given this lack, however, have included the Colors class, which allows you to instantiate a color from a predefined set of basic colors.
Code:
Color c = Colors.Black;
SolidColorBrush brush = new SolidColorBrush (c);
The fact is that the set is made up of just a few colors, but the activities are the answer faster. The same mechanism also applies to the class SystemColors, which contains a small list of colors associated with the operating system.
Code:
Color c = SystemColors.ControlColor;
SolidColorBrush brush = new SolidColorBrush (c);
Another option we have, instead, to instantiate a new color is to use the method FromArgb () just more of the Color class, respectively, passing the value for the alpha channel, the value for red, green, and the blue.
Code:
Color c = Color.FromArgb (255, 255, 255, 255);
SolidColorBrush brush = new SolidColorBrush (c);
Bookmarks