dcinadr
dcinadr

Reputation: 685

WPF Textbox persist visible caret

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

Upvotes: 3

Views: 2992

Answers (2)

kevinarpe
kevinarpe

Reputation: 21319

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

Upvotes: 2

iyalovoi
iyalovoi

Reputation: 191

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"

Upvotes: 2

Related Questions