Opacity Property
Collapse the table of content
Expand the table of content

Brush.Opacity Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets or sets the degree of opacity of a Brush.

Namespace:  System.Windows.Media
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.

public double Opacity { get; set; }

Property Value

Type: System.Double
The value of the Opacity property is expressed as a value between 0 and 1.0. The default value is 1.0.

Dependency property identifier field: OpacityProperty

An Opacity value of 0 indicates that the brush is completely transparent, while a value of 1 indicates that the brush is completely opaque. A value of 0.5 indicates the brush is 50% opaque, a value of 0.725 indicates the brush is 72.5% opaque, and so on. Values less than 0 are treated as 0, while values greater than 1 are treated as 1.

The following illustrations shows a red rectangle with several different Opacity values.

Opacity = 1

Rectangle with 100 percent opacity.
Opacity = 0.7

Red rectangle.
Opacity = 0.5

Rectangle with 50 percent opacity.
Opacity = 0.2

Rectangle with 20 percent opacity.
Opacity = 0

Rectangle with 0% opacity.

An Opacity of 0 applied to any Brush is still hit testable. Only a true null Brush is not hit testable. You could however set IsHitTestVisible to false to remove any hit testing against the UIElement where the Brush is ultimately applied.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2017 Microsoft