UIElement.Opacity 屬性

定義

取得或設定套用至整個 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; }
[<System.Windows.Localizability(System.Windows.LocalizationCategory.None, Readability=System.Windows.Readability.Unreadable)>]
member this.Opacity : double with get, set
Public Property Opacity As Double

屬性值

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 預設值是這個相依性屬性在類別上的初始中繼資料所提供的預設值 UIElementThe 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除非) (也可以看見專案,否則的值將不會套用至實際版面配置 IsVisible trueThe 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) ,則會轉譯該清單專案的淨可見不透明度,就像是 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 NoneNone

適用於

另請參閱