After creating a managed domain with MVVM / WPF

I have a simple POCO here, and INotifyPropertyChangedthis is the interface for the view, which needs to be implemented in the ViewModel, and not in the model.

Now I want to show validation errors in the view next to each text field entered by the user.

I do not want to implement the interface IDataErrorInfoin my models, because it allows me to assume that I am not allowed to touch them, since they come from another Service / Provider.

I do not want to put my method IsCustomerFirstNameLenthValidin the model because I did not have access to it, or I just do not want to pollute my models using an interface that has nothing to do with it!

How can I test my bare POCO`s in the ViewModel and redirect the results to the view showing validation errors?

+3
source share
3 answers

This is not the answer that you are directly looking for, but in order to maintain a separation of concerns, I would not use your domain pocos to compile a viewmodel. I would map domain objects to completely separate viewmodel objects. Thus, all views concerning / plumbing can remain on the viewmodel.

+2
source

It looks like what you call your naked POCOs is ViewModels and that you have access to them.

, IDataErrorInfo ( , , ). ( ) , ValidationRule.

( ) , , WPF.

,
Berryl

+2

view . IDateErrorInfo . , POCO.

, POCO, . (VAB) , , POCO. WPF, Silverlight, , Bennedik .

0

Source: https://habr.com/ru/post/1737827/


All Articles