I've got a custom control that gets bound to an object from view model. The control has its own "mini viewmodel"(implements raisedproperychanged and idataerrorinfo) it its code behind for some specific validation.
There are some properties used internal to this control that can cause the control to be in an invalid state (these properties are inherent to the control, and do not represent properties of the model we are bound to). How can I get these validation errors to "bubble up" so that the property that is bound to this control shows as having a validation error?
For a more clear example. Say I have a person object that I bind to the person property of the custom usercontrol. This control will allow you to edit the sub properties and such of the person. There is additional validation in this control beyond what is normally applied to a person object, such as the control being "invalid" until the user closes a dialog that the control created, or clicked a checkbox indicating they were finished editing. I want these validation errors to propagate out so that the binding to the person property shows the validation error, or more specifically, the VM that contains it.
You've got it the wrong way around - the control sets the value on the ViewModel (through binding) and the ViewModel validates each field and provides an error message through IDataErrorInfo. For more information see: http://codeblitz.wordpress.com/2009/05/08/wpf-validation-made-easy-with-idataerrorinfo/