UIElement.Opacity Property

July 28, 2014

Gets or sets the degree of the object's opacity.

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

public double Opacity { get; set; }
<uiElement Opacity="double" .../>

Property Value

Type: System.Double
A value between 0 and 1.0 that declares the opacity factor, with 1.0 meaning full opacity and 0 meaning transparent. The default value is 1.0.

Dependency property identifier field: OpacityProperty

An Opacity value of 0 does not exclude an object from hit testing. This behavior can be useful for creating imagemap-style overlays of Canvas, Rectangle or other shapes to capture hits on objects that exist at z-orders greater than other visible objects underneath. In order to exclude an object from hit testing, you should set IsHitTestVisible to false.

When Opacity is set on objects that are nested, the effective opacity is the product of all applicable opacity factors. For instance, if an object that has Opacity=0.5 is contained in a Canvas that is also Opacity=0.5, the effective Opacity value is 0.25.

Opacity values greater than 1.0 are treated as 1.0 when the value is used, although obtaining the property value will still give you the original greater-than-one value. Opacity values less than 0 are treated as 0 when the value is used. For instance, setting an Opacity to 2 to cancel out the effects of being contained by an object with 0.5 Opacity does not work; the 2 value is treated as 1.0 even before the nested-object factoring is calculated.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft