I'm doing some validation, I want to do the validation in the ViewModel (yes using MVVM pattern). this is what I am after roughly:
SearchResult srs = _viewModel.Search();
if ( srs.Result == Result.Failed ) {
MessageBox.Show(srs.ErrorMessage);
SetFocusToControl( srs.ControlNameWithError );
}
the SetFocusToControl()
is what requires some help, how do I set focus to a control by 'name'
so if control is named 'CustomerName' is there a way to find it 'by name' and then set it?
of course I'm open to ways on how to do this better - but I cannot move to the Dataform at this point, I was just looking at refactoring this code to get it out of the View.
thanks for your help in advance, Sincerely, J__