February 16, 2011 Leave a comment
By default, the radius of a radial gradient is always half of the height and width of the control. In other words, the gradient will extend exactly to the edge of the control. In the example below, the gradient goes from white to dark blue and reaches dark blue at the edges of the ellipse.
We can change the radius of the gradient using the RadialGradientBrush.RadiusX and RadiusY properties. The default value for both is 0.5, indicating that the gradient takes 1/2 the height or width of the circle to reach the final color.
If we change the radius to 0.25, we reach the final color of the gradient halfway out to the edge of the ellipse:
<RadialGradientBrush x:Name="grad" RadiusX="0.25" RadiusY="0.25"> <GradientStop Color="White" Offset="0.0"/> <GradientStop Color="LightBlue" Offset="0.5"/> <GradientStop Color="DarkBlue" Offset="1.0"/> </RadialGradientBrush>