Here is another way. The selection will also be highlighted.
private void MyMethod()
{
TextBox txt = ...;
txt.LostFocus += new RoutedEventHandler(staticTextBox_LostFocus);
}
private static void staticTextBox_LostFocus(object sender, RoutedEventArgs e)
{
e.Handled = true;
}
source
share