Brushes in Silverlight

Brushes fill the background ,foreground and border of an element.
System.Windows.Media.Brush provides 5 brush classes:
SolidColorBrush
RadialGradientBrush
LinearGradientBrush
ImageBrush
VideoBrush

We shall discuss here about linear and radial brushes.

LinearGradientBrush
Fills element horizontally,vertically or diagonally in linear fashion
GradientStop : Offset can take values from 0 to 1
0: Beginning color of gradient
1: End color of gradient
In order to decide the direction of fill two properties are used:
StartPoint EndPoint
(0,0)            (1,1) : Diagonal Fill
(0,1)             (1,1) : Vertical side-to-side fill
(1,0)            (1,1) : Horizontal top to bottom fill

RadialGradientBrush
Fills element radially and gradiates out from a inner gradient circle.
Inner Gradient circle used 3 properties
RadiusX,RadiusY: to limit the size
GradientOrigin property: Sets the location of point within
the element.
GradientStops can take values from (0,0) to (1,1).

In figure below:
The grid is divided into 2 rows and 4 columns.
For lineargradientbrush the startpoint and the endpoint
values are changed for each rectangle.
Code for one rectangle:
code11

For radialgradient brush the gradientorigin is changed for every ellipse.
Code for one ellipse:
code2

LinearGradientBrush and RadialGradientBrush

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s