Initially this question brought me here: Disable firing TextChanged event
I wondered if jtmach's answer is "clean":
private void mytextbox_LostFocus(object sender, RoutedEventArgs e)
{
this.mytextbox.TextChanged -= this.myTextBox_TextChanged;
if(textbox.Text.ToString().Contains('.'))
{
textbox.Foreground = new SolidColorBrush(Colors.Gray);
textbox.Background = new SolidColorBrush(Colors.White);
}
this.mytextbox.TextChanged += this.myTextBox_TextChanged;
}
Is it OK to unsubscribe TextChanged
-events in another event like this?
Or is it prone to errors because during the LostFocus the TextChanged event could be called (either by the user or by the program)?