Hello guys, i have to admit that i am new into the idea of designing software with MvvM and other accepted patterns, but i am sold to the idea! The obvious consequence of my lack of experience is that i reached a point where my nagging doubts
can no longer be answered by reading documentation. So here i reach the community and ask a couple of questions:
1: I am using sync framework 4.0 and with it i get a bunch of generated proxy classes that is used by my local component to communicate and persist that data, the question is, since those classes implement INotifyPropertyChange and are partial
classes (so it can be extended with validation or whatever) they make perfect classes to use in binding, can i bind to using this classes or i have to create a wrapper class to be on good terms with the best practices? (at first glance for me the
wrapper class appear to give more separation but at the cost of having to recreate all the model + having to do copy the data from proxy to wrapper and back when using the repository).
2: I have a search module, and surpassingly it searches for customers, i can communicate that a particular customer is now selected in the search using the proposed methods in prism documentation (Prism service, the Region Context
or an Event Aggregator) i can see all of that working, but here is my idea.
I was thinking that i could bind the search result list box selected Item to a ActiveCustomer Property on my Search viewmodel, but this ActiveCustomer property would be exposed as an public property of my model that the search viewmodel
is holding, something like model.activeCustomer property on my viewmodel, and on the Customer details viewmodel i bind to that same property hence having the effect i want (you select a different customer on the search, you
see its details) this looks to me as a good solution, is it really that bad to have that dependency?
I am really interested in any feedback tank you!.
Mar 17, 2011 at 3:57 PM
The decision of whether to use your generated classes as ViewModels, or create a class on your own depends on your requirements for the application. While it's not the usual approach, it shouldn't cause problems as long as you don't place too many responsibilities
in one single class.
As for your second concern, if I understood your scenario correctly, you would be using the same instance of the model accross your ViewModels. In my opinion, that doesn't seem to be an invalid possiblity.
You might find the following chapter from the Prism MSDN documentation useful:
Chapter 5: Implementing the MVVM Pattern
Also, you might find the following QuickStarts and Reference Implementation useful to check how this pattern is implemented in Prism:
I hope you find this helpful.
Guido Leandro Maliandi