Caret disappears when the background of a textbox is gray in wpf

て烟熏妆下的殇ゞ 提交于 2019-12-10 23:29:51

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!