Rob Vermeulen
Rob Vermeulen

Reputation: 1970

Is there a way to propagate input validation in model through viewmodel

I have a model with a few properties and in that model I do some validation checks (checking if values don't exceed ranges, if it is a number, if it is a valid postal code etc). These checks should be done by the model, I think.

I have a choice of using one of these validation interfaces: INotifyDataErrorInfo or IDataErrorInfo. I do not have a preference.

I have a viewmodel that exposes many of the model's properties along with a couple of additional, view-specific and housekeeping properties such as IsSelected, IsInScope, IsSaved etc.

The view (in this case a DxGrid from DevExpress) is bound to a collection of viewmodels, thus it is hiding the model's validation checks (it is bound to the viewmodel's interface). Is there an easy way to propagate the model's validation checks to the view, and through the viewmodel?

Edit: fyi, I'm using Simple MVVM Toolkit, which has incorporated INotifyDataErrorInfo in its Model base class, but not in its Viewmodel base class.

Upvotes: 1

Views: 248

Answers (0)

Related Questions