Hi,
I bind a PropertyGrid to a pretty complex object generated by Linq2SQL.
I implemented IDataErrorInfo on the object.
Further let the PropertyGrid autogenerate the properties.
Now I have two Problems - this[string ColumnName] never gets called.
Next - the property Grid tries to bind "Error" (I know I can fix this in code behind - but this would break my so far "no code behind" MVVM design) - but this isn't very important.
Last not least I implemented "IsValid" like in the following snippet.
I further know that I could decorate my object with attributes - but the reason to use your PropertyGrid is that the object is large (a lot of properties) and I don't want to define all these things. And it would be hard without touching the Linq2Sql autogenerated code.
Main Problem - no validation (this[string ColumnName] occurs.
Manfred
I bind a PropertyGrid to a pretty complex object generated by Linq2SQL.
I implemented IDataErrorInfo on the object.
Further let the PropertyGrid autogenerate the properties.
Now I have two Problems - this[string ColumnName] never gets called.
Next - the property Grid tries to bind "Error" (I know I can fix this in code behind - but this would break my so far "no code behind" MVVM design) - but this isn't very important.
Last not least I implemented "IsValid" like in the following snippet.
public static bool IsValid(this DependencyObject obj) { // The dependency object is valid if it has no errors, //and all of its children (that are dependency objects) are error-free. return !Validation.GetHasError(obj) && GetVisualTreeChildren(obj) .OfType<DependencyObject>() .All(child => IsValid(child)); } //VisualTreeHelper don't have a method to get all the children of a visual object private static IEnumerable GetVisualTreeChildren(DependencyObject parent) { for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++) yield return VisualTreeHelper.GetChild(parent, i); }//OK handler in VM using the IsValid extension protected override bool HandleOKCanExecute(object arg) { if (this.TheView != null) { return(this.TheView.IsValid()); } return (false); }I further know that I could decorate my object with attributes - but the reason to use your PropertyGrid is that the object is large (a lot of properties) and I don't want to define all these things. And it would be hard without touching the Linq2Sql autogenerated code.
Main Problem - no validation (this[string ColumnName] occurs.
Manfred