UIElement.Opacity UIElement.Opacity UIElement.Opacity UIElement.Opacity Property

定義

取得或設定套用至整個 UIElement (在 使用者介面 (UI)user interface (UI) 中呈現時) 的不透明度因數。Gets or sets the opacity factor applied to the entire UIElement when it is rendered in the 使用者介面 (UI)user interface (UI). 這是相依性屬性。This is a dependency property.

public:
 property double Opacity { double get(); void set(double value); };
[System.Windows.Localizability(System.Windows.LocalizationCategory.None, Readability=System.Windows.Readability.Unreadable)]
public double Opacity { get; set; }
member this.Opacity : double with get, set
Public Property Opacity As Double

屬性值

不透明度因素。The opacity factor. 預設不透明度為 1.0。Default opacity is 1.0. 值必須介於 0.0 到 1.0 之間。Expected values are between 0.0 and 1.0.

備註

1.0 的預設值是提供初始的中繼資料,在此相依性屬性的預設值UIElement類別。The 1.0 default value is the default provided by the initial metadata of this dependency property on the UIElement class. 其他衍生的類別可能可以藉由覆寫其類別建構函式內的中繼資料變更此預設值。Other derived classes may potentially change this default value by overriding the metadata from within their class constructor.

Opacity不會套用至實際的配置中,除非也是可見的項目 (IsVisibletrue)。The value of Opacity won't be applied to actual layout unless the element is also visible (IsVisible is true).

Opacity 會套用至從父項目在元素樹狀結構子項目,但巢狀的不透明度設定並不表示在個別的子元素的屬性值的顯示效果。Opacity is applied from parent elements on down the element tree to child elements, but the visible effects of the nested opacity settings aren't indicated in the property value of individual child elements. 比方說,如果清單有 50%(0.5) 的不透明度,其中一個清單項目有其本身設為 20%(0.2) 的不透明度,net 可見的不透明度,該清單項目將呈現如同它是 10%(0.1),但屬性值的清單項目Opacity屬性仍會是 0.2 查詢時。For instance, if a list has a 50% (0.5) opacity and one of its list items has its own opacity set to 20% (0.2), the net visible opacity for that list item will be rendered as if it were 10% (0.1), but the property value of the list item Opacity property would still be 0.2 when queried.

即使宣告或評估的不透明度為 0,項目仍參與輸入的事件和命令,並可能可設定焦點。Even if the declared or evaluated opacity is 0, an element still participates in input events and commands, and is potentially focusable. 這方面很有用,例如您可以使用不透明度為零的物件 (例如圖形),加上遮罩時以透明的項目基礎物件。This aspect can be useful, for instance you can use an opacity-zero object (such as a shape) for masking underlying objects with transparent elements. 不透明度為零的物件,然後可處理所有輸入的事件處理基礎的區域。The opacity-zero object can then handle all the input event processing for an underlying area. 不過,Background或是Fill之物件的圖形應該設定為值,即使它是Transparent,否則為未啟用點擊測試,並沒收到任何事件。However, the Background or Fill of the object or shape should be set to a value, even if it is Transparent, otherwise hit testing is not enabled, and no events are received.

相依性屬性資訊Dependency Property Information

識別項欄位Identifier field OpacityProperty
若要設定的中繼資料屬性 trueMetadata properties set to true None

適用於

另請參閱