在WPF文本框中隐藏插入符号
答
插入符号是文本编辑器中的当前插入位置。光标是鼠标光标的形状。
无法在读写文本框中禁用插入符号。相反,将CaretBrush更改为透明。
TextBox txt = ...;
// Hide the caret.
txt.CaretBrush = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
// Show the caret.
txt.CaretBrush = null; // use default Brush
答
使用TextBox.CaretBrush
属性,可以使光标的颜色与背景颜色相同或Transparent
。
相关:http://stackoverflow.com/questions/935769/wpf-passwordbox-caret – 2010-10-11 20:49:29
谢谢,工作。 – 2010-10-11 21:08:10