views:

251

answers:

1

Hi,

Here is the situation: I have a dataset bound to a WPF window. The dataset implements the IDataErrorInfo, so when a value is changed in the window, a validation occurs for the specific property changed. During validation, I may find out there is another control in the window I need to validate. I know only the field name in the Dataset that I need to validate, and not the actual control that binds to this field. So my questions are: 1. How can I find out what control binds to a specific field in a Dataset? 2. How do I trigger validation on that control by code?

Thanks!

+1  A: 

Two options as I see it:

  1. I think one way to handle this is in the setter for the property that's changed, clear the property that's no longer valid (if it is indeed not valid now).
  2. Another trick might be in the setter of the 1st property to raise a PropertyChanged event on the 2nd property, to force the view to reevaluate it.

I would prefer the 1st option, since you know changing the 1st property has a chance to invalidate the other property.

Aviad P.
I like more the 2dn option, but how can I raise a PropertyChanged event when I know only the name of the field in the dataset? I need to find out which property is bound to this field.
ML123
From the setter of your `GasType` property raise an `OnPropertyChanged("CarType")`.
Aviad P.
I may be missing something here. AFAIK, OnPropertyChanged is a WPF method. The data model is DataSet. How can I call OnPropertyChanged from the dataset?
ML123
I meant your own implementation of `OnPropertyChanged` something that you might have implemented as part of your implementation of `INotifyPropertyChanged` - In short I meant for you to raise the `PropertyChanged` event for the other property.
Aviad P.