top of page

Silverlight- SolidColorBrush Example

Updated: Mar 18, 2019

In this article we will be seeing how to create Silverlight SolidColorBrush using Visual studio 2010.

SolidColorBrush is used to paint an area with a solid color.

Namespace: System. Windows. Media

Assembly: PresentationCore (in PresentationCore.dll)


It is defined by the following properties.

  1. Color

  2. Opacity

  3. Relative Transform

  4. Transform


It is used to specify the color of this SolidColorBrush.


It is used to specify the degree of opacity of a Brush.

Relative Transform:

It is used to specify the transformation that is applied to the brush using relative coordinates.


It is used to specify the transformation that is applied to the brush. This transformation is applied after the brush's output has been mapped and positioned.

Steps Involved:

Creating a Silverlight Application:

  1. Open Visual Studio 2010.

  2. Go to File => New => Project.

  3. Select Silverlight from the Installed templates and choose the Silverlight Application template.

  4. Enter the Name and choose the location.

  5. Click OK.

  6. In the New Silverlight Application wizard check the "Host the Silverlight Application in a new Web site".

  7. Click OK.

Creating the UI:

Open MainPage.xaml file and replace the code with the following.

<UserControl x:Class="SilverlightSolidColorBrush.MainPage"  xmlns=""  xmlns:x=""  xmlns:d=""  xmlns:mc=""  mc:Ignorable="d"  d:DesignHeight="300" d:DesignWidth="400"> <Canvas Height="200" Width="200" Background="White"> <Rectangle Height="50" Width="50" Canvas.Left="75" Canvas.Top="75"> <Rectangle.Fill> <SolidColorBrush> <SolidColorBrush.Color> <Color A="255" R="250" G="60" B="90"></Color> </SolidColorBrush.Color> </SolidColorBrush> </Rectangle.Fill> </Rectangle> </Canvas> </UserControl>

Testing the solution:

  1. Build the solution.

  2. Hit ctrl+F5.



bottom of page