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;
}
精彩评论