TextBoxBase.SelectionOpacity 属性

定义

获取或设置 SelectionBrush 的不透明度。Gets or sets the opacity of the SelectionBrush.

public:
 property double SelectionOpacity { double get(); void set(double value); };
public double SelectionOpacity { get; set; }
member this.SelectionOpacity : double with get, set
Public Property SelectionOpacity As Double

属性值

SelectionBrush 的不透明度。The opacity of the SelectionBrush. 默认值为0.4。The default is 0.4.

示例

下面的示例创建一个TextBox并添加文本 "这是一些文本"。The following example creates a TextBox and adds the text, "This is some text." 该示例将SelectionBrush属性设置为红色, 将SelectionOpacity属性设置为 0.5, 以自定义所选文本的外观。The example sets the SelectionBrush property to red and the SelectionOpacity property to 0.5 to customize the appearance of selected text.

<TextBox SelectionBrush="Red" SelectionOpacity="0.5"
         Foreground="Blue" CaretBrush="Blue">  
  This is some text.
</TextBox>

下图显示了前面TextBox示例中选定了其文本的。The following illustration shows the TextBox from the preceding example with its text selected.

带有红色 SelectionBrush 的 TextBoxTextBox with a red SelectionBrush
在 SelectionOpacity 设置为0.5 的文本框中选定的文本Selected text in a TextBox with SelectionOpacity set to 0.5

注解

如果SelectionOpacity设置为 0, 则是SelectionBrush透明的, 并且不可见。If SelectionOpacity is set to 0, the SelectionBrush is transparent and is not visible. 如果SelectionOpacity设置为1.0 或更高SelectionBrush , 则不透明, 并且所选文本将不可见。If SelectionOpacity is set to 1.0 or greater, the SelectionBrush is opaque and the selected text is not visible.

适用于