开发者

WPF Textbox persist visible caret

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜