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:
- if keep datalist inside viewmodel, how other view model can access it
- if keep datalist in application view can access , whether view model able update through binding
- 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
Post a Comment