共用方式為


VisualElement.Opacity 屬性

定義

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

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

屬性值

System.Double

不透明度值。 預設不透明度為 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;

適用於