How to: Paint an Area with a Solid Color
To paint an area with a solid color, you can use a predefined system brush, such as Red or Blue, or you can create a new SolidColorBrush and describe its Color using alpha, red, green, and blue values. In XAML, you may also paint an area with a solid color by using hexidecimal notation.
The following examples uses each of these techniques to paint a Rectangle blue.
Using a Predefined Brush
In the following example uses the predefined brush Blue to paint a rectangle blue.
Using Hexadecimal Notation
The next example uses 8-digit hexadecimal notation to paint a rectangle blue.
Using ARGB Values
<Rectangle Width="50" Height="50"> <Rectangle.Fill> <SolidColorBrush> <SolidColorBrush.Color> <!-- Describes the brush's color using RGB values. Each value has a range of 0-255. R is for red, G is for green, and B is for blue. A is for alpha which controls transparency of the color. Therefore, to make a completely transparent color (invisible), use a value of 0 for Alpha. --> <Color A="255" R="0" G="0" B="255" /> </SolidColorBrush.Color> </SolidColorBrush> </Rectangle.Fill> </Rectangle>
Dim myRgbRectangle As New Rectangle() myRgbRectangle.Width = 50 myRgbRectangle.Height = 50 Dim mySolidColorBrush As New SolidColorBrush() ' Describes the brush's color using RGB values. ' Each value has a range of 0-255. mySolidColorBrush.Color = Color.FromArgb(255, 0, 0, 255) myRgbRectangle.Fill = mySolidColorBrush
For other ways of describing color, see the Color structure.