I have a WPF application with a dialog box that allows the user to edit the settings of an object. I'm using MVVM for this dialog. My view Model Object for this dialog implements the IDataErrorInfo interface.
One of the fields on the form is a ComboBox that is mapped to a property of the View Model object that is an enum. There are other fields on the form whose validation logic depends upon the value of the field bound to the ComboBox.
Individually, when the values of the different fields are entered, they validate and the dialog displays the correct error status. That is, when you create a new object and edit the form to specify values different from the defaults, the error state of each control is displayed properly. My problem is that when you edit an existing object, and you change the selected value in the ComboBox, the value that may be specified in a field that appears further down the dialog may be invalid, but the error state is not being displayed.
Here's the code that runs when you change the selected value of the ComboBox:
private void TypePicker_SelectionChanged( object sender, SelectionChangedEventArgs e ) {
IsDirty = true;
MyCommands.SaveChanges.CanExecute( this, OkButton );
e.Handled = true;
}
MyCommands is a class; the commands are static properties of that class. IsDirty is a bool DependencyProperty belonging to the dialog.
How do I get the other fields to validate when I change the selected value in the ComboBox?
Aucun commentaire:
Enregistrer un commentaire