Associate the IDataErrorInfo Property with the IsEnabled Window

I have an additional WPF window with some controls that the user must fill out correctly before clicking the Ok button.

I already implemented the IDataErrorInfo interface to check all the properties associated with the user interface controls.

Now I would like the IsEnabled property of the Ok button to be True only if all the controls are valid, otherwise it should be set to False strong>.

It should be easy, but I cannot find the right solution. Do you have any suggestions?

Thanks in advance!

+3
source share
1 answer

Ciao; -)

I think you could bind a property IsEnabledto a button (for example) to a property of IDataErrorInfo.Erroryour data through an IValueConverter (which you need to implement) that converts from stringto bool(for example, if a value String.Emptythan return true).

Another solution is to use Commandand enable this logic in CanExecute: that way you just need to associate Commandwith yours Button. NTN

+1
source

All Articles