开发者

WPF Textbox persist visible caret

开发者 https://www.devze.com 2022-12-30 13:25 出处:网络
Is there a way to make the caret in a textbox visible eve开发者_开发百科n when the textbox has lost focus?Maybe this is not you want, but i have used it. Actually you can set FocusManager.IsFocusScope

Is there a way to make the caret in a textbox visible eve开发者_开发百科n when the textbox has lost focus?


Maybe this is not you want, but i have used it. Actually you can set FocusManager.IsFocusScope="True" on your textbox, so it will always has focus it's own focus. It means caret will be always visible. You can enable/disable such behaviour FocusManager.IsFocusScope="True"/"False"


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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消