SolidColorBrush WPF in VB.NET

This article demonstrates how to use SolidColorBrush in WPF using XAML.
  • 3015

This article demonstrates how to use SolidColorBrush in WPF using XAML.

Solid Color Brush

The SolidColorBrush represents the solid color brush in XAML. The Color attribute of the tag represents the color used in the brush. The Opacity property of the SolidColorBrush represents the transparency of the color. For example, you can specify its alpha, red, blue, and green channels or use one of the predefined color provided by the Colors class.

Creating rectangle control in XAML

The following xaml code represent the Rectangle control in xaml.

XAML code

<Rectangle Height="100" HorizontalAlignment="Left" Margin="10,120,0,0" Name="Rectangle2" VerticalAlignment="Top" Width="200"></Rectangle>

Creating a Solid Brush

The SolidColorBrush element in XAML creates a brush with a solid color. The following code creates a solid color brush with a turquoise color.

<SolidColorBrush Color="Turquoise" />

Using a SolidColorBrush to paint the Fill of a Rectangle

The following code is used to paint the fill of a rectangle.

<Rectangle Width="180" Height="200">

<Rectangle.Fill>

<SolidColorBrush Color="Turquoise"/>

</Rectangle.Fill>

</Rectangle>

Now the rectangle looks like this.

scb1.gif

Figure1.gif

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.