Skip to content

ModelValidation with separate model class #336

Answered by canton7
Catalan-1ap asked this question in Q&A
Discussion options

You must be logged in to vote

It's to be expected. It's exactly the same problem as if you bind to properties of an object where that object does not implement INPC.

Validation works through INotifyDataErrorInfo. When you bind to a property, WPF checks to see whether the parent object implements that interface, and if it does, it subscribes to validation events.

The parent object of your Title property is the Publication class. So that's the class which needs to implement INotifyDataErrorInfo (usually, with Stylet, by subclassing ValidatingModelBase).

This is just another application of the general WPF rule, which is "Do not bind to things which are not ViewModels"

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Catalan-1ap
Comment options

@canton7
Comment options

Answer selected by Catalan-1ap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants