Tag: XAML
Textbox caret
by TLCube on Feb.15, 2010, under Programming
If you are using dark colors your applications, there is possibly that TextBox caret is color is black. This will make editing TextBox text more difficult. TextBox caret color is inverse to backround color, but when backround color is set to null, the default black color is used (picture 1).
There is couple of workarounds. The simplest is set TextBox backround color same color as where parent color is (picture 2). There is another workaround here.
Now WPF 4.0 has new CaretBrush property. You can simply set caret color just like any other colors (Picture 3).
<TextBox Name="textBox3" CaretBrush="Orange"/><code>
You can also specify a more complex brush like a LinearGradient (picture 4):
<TextBox.CaretBrush>
<LinearGradientBrush StartPoint="0,0"
EndPoint="0,1">
<GradientStop Color="White"
Offset="0" />
<GradientStop Color="Orange"
Offset=".5" />
<GradientStop Color="White"
Offset="1" />
</LinearGradientBrush>
</TextBox.CaretBrush>
Time to say goodbye for caret problems.
