Bug with "nested_name_binding".

Dec 3, 2010 at 8:08 PM

I think I found a bug.

I tried to use nested object binding using underscores in name. I had a ViewModel, that had instance of another business object named Customer, this one has property Name and implements both INotifyPropertyChanged and IDataErrorInfo. Then I have View, that has textbox with name "Customer_Name". I would expect, that both binding and validation would work. But it seems validation doesnt fire any of IDataErrorInfo getters.

I tried to locate problem and I found out, this is caused in class ViewModelBinder, static method BindProperties, line 76. When this kind convention is used, it uses "property.GetType()" as ViewModel it checks conventions from. Then in this case, it uses System.String as VM, which is clearly wrong. This can be easily solved using "property.DeclaringType" instead, which makes Customer type as VM and if this type implements IDataErrorInfo it will turn on binding validation correctly.

I hope I explained it correctly.

Dec 3, 2010 at 10:08 PM

Thanks for tracking down the issue! I'm creating a ticket to remind me to fix it soon.

Dec 4, 2010 at 7:55 AM

Cool. Thank you.