通过


TextBoxBase.SelectionBrush 属性

定义

获取或设置突出显示所选文本的画笔。

public:
 property System::Windows::Media::Brush ^ SelectionBrush { System::Windows::Media::Brush ^ get(); void set(System::Windows::Media::Brush ^ value); };
public System.Windows.Media.Brush SelectionBrush { get; set; }
member this.SelectionBrush : System.Windows.Media.Brush with get, set
Public Property SelectionBrush As Brush

属性值

突出显示所选文本的画笔。

示例

以下示例创建并 TextBox 添加文本“这是一些文本”。该示例将 SelectionBrush 属性设置为红色, SelectionOpacity 并将属性设置为 0.5 以自定义所选文本的外观。

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

下图显示了 TextBox 上一个示例中的选定文本。

带红色 SelectionBrush SelectionBrush 设置为红色的 TextBox 中的选定文本

注解

可以通过设置和SelectionOpacity属性来指定突出显示所选文本的SelectionBrush画笔。 该 SelectionOpacity 属性指定 . SelectionBrush的不透明度。

适用于