3

I have a WPF sub window with some input controls that the user has to correctly fill before pressing Ok button.

I have already implemented the interface IDataErrorInfo to validate all properties bound to UI Controls.

Now I would like that the IsEnabled property of Ok button is True only if ALL controls are valid, otherwise it has to be set to False.

It should be easy but I cannot find the correct solution. Do you have any suggestion?

Thanks in advance!

4

1 回答 1

1

再见 ;-)

我认为您可以通过转换为的 IValueConverter (您必须实现)将按钮的属性绑定到(例如)数据的属性(IsEnabled例如,如果值 if比 return )。IDataErrorInfo.ErrorstringboolString.Emptytrue

另一种解决方案是使用Commands 并将此逻辑包含在CanExecute: 中,这样您只需将Command与您的Button. 高温高压

于 2009-01-15T13:27:40.157 回答