VisualElement.Opacity 屬性

定義

取得或設定套用至項目 (呈現時) 的不透明度值。 這是可繫結屬性。

public double Opacity { get; set; }
member this.Opacity : double with get, set

屬性值

不透明度值。 預設不透明度為 1.0。 值會在設定時限制在 0 到 1 之間。

備註

除非 IsVisible 為 true ,否則不透明度值沒有任何作用。 不透明度會繼承至專案階層。 如果父系具有 0.5 不透明度,且子系具有 0.5 不透明度,則子系會以有效的 0.25 不透明度轉譯。 將不透明度設定為 0 具有輸入元素的未定義行為。

下列範例會將版面配置不透明度設定為 0.5,並將其中一個子系的不透明度設定為 0.5,讓子系 25% 不透明。

StackLayout stack = new StackLayout ();
Button button1 = new Button {Text="A Button"};
Button button2 = new Button {Text="Another Button"};

stack.Children.Add (button1);
stack.Children.Add (button2);

// The stack and everything in it will become 50% opaque
stack.Opacity = 0.5;

// button1 will become 25% opaque while the stack and button2 remane 50% opaque
button1.Opacity = 0.5;

適用於