private void Vm_FocusOnField(object sender, EventArgs e) { string field = sender.ToString(); if (field != "Reinit") { _currentFocusElementName = sender.ToString(); //if (!string.IsNullOrEmpty(_currentFocusElementName)) //{ // Application.Current.Dispatcher.Invoke((Action)delegate // { // FrameworkElement elem = FindName(_currentFocusElementName) as FrameworkElement; // if(elem!=null) // elem.Focus(); // }); //} } else { Application.Current.Dispatcher.Invoke((Action) delegate { _currentFocusElementName = string.Empty; OperatorField.Focus(); }); } }
private void Control_Loaded(object sender, RoutedEventArgs e) { OperatorField.Focus(); //if (this.DataContext != null) //{ // OperatorToolLotViewModel vm = DataContext as OperatorToolLotViewModel; // if (vm != null) // { // vm.FocusOnInvalidTextBox += Vm_FocusOnField; // } //} }