

For example, an alpha value of 0 indicates that a color is completely transparent, while a value of 255 indicates the color is completely opaque. The typical range for each of these values is 0-255. The static FromArgb enables you to specify the color's alpha, red, green, and blue values. SolidColorBrush mySolidColorBrush = new SolidColorBrush()
Gradient colors how to#
The following example shows how to set the Color property of a SolidColorBrush using a predefined color. You can use a predefined color from the Colors class or you can create a Color using the static FromArgb method. Button myButton = new Button() Ĭreate a SolidColorBrush and set its Color property using a Color structure. In the following example, the Background of a Button is set to Red. Use one of the predefined brushes provided by the Brushes class. To paint an area with a solid color in code, use one of the following options. The second brush's color is described using hexadecimal notation. The first brush's color is described using a predefined color name. In the following example, the Background properties of two Button elements are set to fully-opaque red. This syntax is more verbose but enables you to specify additional settings, such as the brush's opacity. Use property tag syntax to describe a SolidColorBrush. In the following example, the Background of a Button is set to fully-opaque red using hexadecimal notation. This approach enables you to create colors that are partially transparent. Additionally, the color can be specified as "# aarrggbb" where aa specifies the alpha value, or transparency, of the color. The format for specifying a color from the 32-bit palette is " #rrggbb", where rr is a two digit hexadecimal number specifying the relative amount of red, gg specifies the amount of green, and bb specifies the amount of blue. Ĭhoose a color from the 32-bit color palette by specifying the amounts of red, green, and blue to combine into a single solid color. For a list of other predefined solid color brushes, see the static properties of the Brushes class. For example, you can set a button's Background to "Red" or "MediumBlue". Select a predefined solid color brush by name.

To paint an area with a solid color in XAML, use one of the following options. The following sections describe the different ways to paint with a SolidColorBrush.
Gradient colors windows#
To accomplish this task, Windows Presentation Foundation (WPF) provides the SolidColorBrush class. One of the most common operations in any platform is to paint an area with a solid Color. This topic describes how to use SolidColorBrush, LinearGradientBrush, and RadialGradientBrush objects to paint with solid colors, linear gradients, and radial gradients.
