How Many type of gradient brushes are available like LinearGradientBrush, SolidColorBrush? and when we create a GradientStop how the offset works?
LinearGradientBrush LGB = new LinearGradientBrush();
LGB.StartPoint = new Point(0, 0);
LGB.EndPoint = new Point(0, 1);
LGB.GradientStops.Add(new GradientStop(Color.FromRgb(255,251,255) , 0));
LGB.GradientStops.Add(new GradientStop(Color.FromRgb(206,207,222), 1));
LGB.GradientStops.Add(new GradientStop(Color.FromRgb(0, 247, 0), 2));
rect.Fill = LGB;
Why the third one "Color.FromRgb(0, 247, 0)" is not reflecting?
Please suggest,where i am wrong?
The GradientStop.Offset property is a value which ranges from 0.0 to 1.0. From the MSDN documentation:
A value of 0.0 specifies that the stop is positioned at the beginning of the gradient vector, while a value of 1.0 specifies that the stop is positioned at the end of the gradient vector.
Change your second stop's offset to 0.5 and your third's to 1.0 and it should work.
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