XAML SolidColorBrush

SolidColorBrush is used to draw graphics objects with a solid color. This article shows how to use SolidColorBrush element of XAML.
  • 5521

SolidColorBrush

The <SolidColorBrush/> represents the solid color brush in XAML. The Color attribute of the tag represents the color used in the brush. For example, the following code creates a solid color brush with blue color.

<SolidColorBrush Color="Blue" />

The Color attribute can also be a hex value instead of the color name. The following code uses hex value of a color.

<SolidColorBrush Color="#FFFFFF" />

The following code fills a rectangle with black color.

<Window xmlns="http://schemas.microsoft.com/winfx/avalon/2005"
  xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005">

<Rectangle Width="200" Height="40" Stroke="Blue" StrokeThickness="1">
    <Rectangle.Fill>
         <SolidColorBrush Color="#000000" />
    </Rectangle.Fill>
</Rectangle>

</Window>

The output looks like Figure 1, which is a filled rectangle with black color.

 BrushesImg1.gif

Figure 1. Rectangle with a solid brush

Further Readings

You may also want to read these related articles.

Ask Your Question 

Got a programming related question? You may want to post your question here
© 2020 DotNetHeaven. All rights reserved.