use of mvvm pattern in wpf application -


i new wpf , designing client-server application using wpf ui have 1 view - view model, datalist , communication model view , view model form 1 user control following doubts:

  1. if keep datalist inside viewmodel, how other view model can access it
  2. if keep datalist in application view can access , whether view model able update through binding
  3. it design if view model calls communication model directly or should keep wraper class in between.

thanx

sarika

you should think using repository pattern access list of items. viewmodels should work against abstraction of repository (e.g. ipeoplerepository), , should pass concrete implementation of repository viewmodel via injection (e.g. through constructor injection). concrete implementation can call communication model retrieve list of items.

typically, repository return collection type not specific wpf. you'll want wrap in observablecollection on viewmodel, ui notified of changes collection.

whether each viewmodel retrieves new reference collection, or if access same collection, depend on use case, long collection exposed property on datacontext (typically viewmodel), you'll able bind collection display , update view.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -