当 wpf 中文本框的背景为灰色时,插入符号消失 [英] Caret disappears when the background of a textbox is gray in wpf

查看:36
本文介绍了当 wpf 中文本框的背景为灰色时,插入符号消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 wpf 中有一个文本框定义如下:

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?

推荐答案

试试 CaretBrush="Tomato" CaretIndicator 使用的颜色可能与 Background 相同目前.

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

所以说:

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

Tomato 只是 c 的一个例子.选择一种与背景有足够差异的颜色,使其具有可展示性.

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

这篇关于当 wpf 中文本框的背景为灰色时,插入符号消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆