2

I have a textbox in wpf defined as follow:

  <TextBox Grid.Column="4" Grid.Row="1" x:Name="InputDirectory" Margin="2" Background="Gray"/>

when I run application, it doesn't show caret, if I remove background colour or change it to other colours ( I tested white, black and blue) the caret appears.

How can I make sure that caret appears when background is Gray?

mans
  • 17,104
  • 45
  • 172
  • 321
  • 2
    http://stackoverflow.com/questions/9290667/textbox-caret-styling may be helpful - if the caret is the same colour as the background you'll need to change the caret colour. – dash Mar 28 '14 at 10:37

1 Answers1

5

Try CaretBrush="Tomato" the color used by the CaretIndicator might be the same as the Background currently.

So say:

<TextBox x:Name="InputDirectory"
          Grid.Row="1"
          Grid.Column="4"
          Margin="2"
          Background="Gray"
          CaretBrush="Tomato" />

Tomato is just an example ofc. Pick a color with enough of a difference to your background to make it presentable.

Viv
  • 17,170
  • 4
  • 51
  • 71
  • Thanks. That solved the problem of caret colour, but mouse pointer is also hidden. How can I change the mouse pointer colour? – mans Mar 28 '14 at 11:42
  • @mans That should prolly be a separate question. However you can already find the answer for that [Here](http://stackoverflow.com/a/410517/1834662). The mouse cursor comes from the system. So to modify it's color you might have to provide a custom cursor for your TextBox's `IBeam` in your project and apply them for control's that require it than use the system's provided ones. If you can get away with not needing the `IBeam`, you can just use a different cursor that would show through such as `Cursor="Hand"` – Viv Mar 28 '14 at 12:20