WPF 文本框保持可见插入符号 [英] WPF Textbox persist visible caret

查看:35
本文介绍了WPF 文本框保持可见插入符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使文本框失去焦点,有没有办法让文本框中的插入符号可见?

Is there a way to make the caret in a textbox visible even when the textbox has lost focus?

推荐答案

这是另一种方式.所选内容也将保持突出显示.

Here is another way. The selection will also remain highlighted.

private void MyMethod()
{
    TextBox txt = ...;
    txt.LostFocus += new RoutedEventHandler(staticTextBox_LostFocus);
}

private static void staticTextBox_LostFocus(object sender, RoutedEventArgs e)
{
    e.Handled = true;
}

这篇关于WPF 文本框保持可见插入符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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