What is the the differnce between solidcolorbrush and brush, In WPF (C#).
SolidColorBrush br = new SolidColorBrush(Colors.Red);
and
Brush br = Brushes.Red;
To answer your question No difference.
Brushes.Red
returns SolidColorBrush
only. Its definition is like:
public static SolidColorBrush Red { get; }
You can assume its default template which Microsoft provides you for basic colors.
Use SolidColorBrush constructor in case you want to provide your own custom A,R,G,B values for color.
This will get you actual Red
color:
SolidColorBrush anotherBrush =
new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
This will get you Red color with G
component set to 100 byte
and B
component set to 50 byte
.
SolidColorBrush anotherBrush =
new SolidColorBrush(Color.FromArgb(255, 255, 100, 50));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With