TextBoxBase.SelectionBrush TextBoxBase.SelectionBrush TextBoxBase.SelectionBrush TextBoxBase.SelectionBrush Property


获取或设置会突出显示选定文本的画笔。Gets or sets the brush that highlights selected text.

 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


会突出显示选定文本的画笔。The brush that highlights selected text.


下面的示例创建一个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示例中选定了其文本的。The following illustration shows the TextBox from the preceding example with its text selected.

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


可以通过设置SelectionBrushSelectionOpacity属性来指定突出显示选定文本的画笔。You can specify the brush that highlights selected text by setting the SelectionBrush and SelectionOpacity properties. 属性指定的SelectionBrush不透明度。 SelectionOpacityThe SelectionOpacity property specifies the opacity of the SelectionBrush.