问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/22710355/caret-disappears-when-the-background-of-a-textbox-is-gray-in-wpf