Using RadialGradientBrush for painting WPF in VB.NET

This article demonstrates how to use RadialGradiantBrush to paint area in WPF Application.
  • 1946

A RadialGradiantBrush paints an object or specified area with a radial gradient. A radial gradient blends two or more colors across a circle. You can use GradiantStop objects to specify the colors in the gradient and their positions. In the following example with the help of a RadialGradiantBrush we will paint the Fill of a Rectangle. See the following illustration which shows the painted rectangle:

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   HorizontalAlignment="Center" VerticalAlignment="Center">
    <Rectangle Width="200" Height="150">
      <Rectangle.Fill>
        <RadialGradientBrush Center="0.45,0.5" RadiusX="0.3" RadiusY="0.5" GradientOrigin="0.25,0.4">
          <GradientStop Color="White" Offset="0" />
          <GradientStop Color="blue" Offset="0.5" />
          <GradientStop Color="red" Offset="1" />
        </RadialGradientBrush>
      </Rectangle.Fill>
    </Rectangle>
 
</Page>
 

Painted Rectangle using a RadialGradientBrush

radial.gif

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.