TextBox.CaretBrush Property
Silverlight
Gets or sets the brush that is used to render the vertical bar that indicates the insertion point.
Namespace: System.Windows.Controls
Assembly: System.Windows (in System.Windows.dll)
<TextBox> <TextBox.CaretBrush> singleBrush </TextBox.CaretBrush> </TextBox>
<TextBox CaretBrush="colorString"/>
XAML Values
Property Value
Type: System.Windows.Media.BrushA brush that is used to render the vertical bar that indicates the insertion point.
Dependency property identifier field: CaretBrushProperty.
The following example sets the CaretBrush property for a TextBox in XAML, C#, and Visual Basic.
public void AddTB() { TextBox MyTB1 = new TextBox(); MyTB1.Text = "HelloWorld"; //Setting the color of the caret in the first text box to blue SolidColorBrush MyBrush1 = new SolidColorBrush(); MyBrush1.Color = Colors.Blue; MyTB1.CaretBrush = MyBrush1; TextBox MyTB2 = new TextBox(); MyTB2.Text = "HelloWorld"; //Setting the color of the caret in the second text box to green SolidColorBrush MyBrush2 = new SolidColorBrush(); MyBrush2.Color = Colors.Green; MyTB2.CaretBrush = MyBrush2; MySP.Children.Add(MyTB1); MySP.Children.Add(MyTB2); }
Public Sub AddTB() Dim MyTB1 As TextBox = New TextBox MyTB1.Text = "HelloWorld" 'Setting the color of the caret in the first text box to blue Dim MyBrush1 As SolidColorBrush = New SolidColorBrush MyBrush1.Color = Colors.Blue MyTB1.CaretBrush = MyBrush1 Dim MyTB2 As TextBox = New TextBox MyTB2.Text = "HelloWorld" 'Setting the color of the caret in the second text box to green Dim MyBrush2 As SolidColorBrush = New SolidColorBrush MyBrush2.Color = Colors.Green MyTB2.CaretBrush = MyBrush2 MySP.Children.Add(MyTB1) MySP.Children.Add(MyTB2) End Sub
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.