Hi! I've created a WCF RIA Service that I'd like to use with a WPF application. I've added several System.ComponentModel.DataAnnotations validation rules on the entities meta-data, all which work great on the server when I call .SubmitChanges(changeSet) from the client. I'd also like to validate my entities on the client side before I sumbit my changes to the server but I have no idea how to do so. Any help in this regard would be greatly appreciated! Thanks....
As far as I know, there is no WCF RIA Services for WPF (although I'd be glad to be proven wrong, as I am waiting for this...), so you have to do the client-side work yourself.
Use the VisualTreeHelper to go over every control in your form, and recursively if the control is a panel. For each control, have a list of potentially-bound properties (I guess there is only one in this case). For example, a TextBox will potentially have its TextBoxProperty bound, a CheckBox will have its IsCheckedProperty bound. Use BindingOperation.GetBinding to get a Binding instance, which gives you the Source and Path properties. Now use reflection on the source to see if there is a data annotation associated with it. If there is, check it.
Yes, it is a lot of code.