Home:ALL Converter>Where should the data be stored in MVVM?

Where should the data be stored in MVVM?

Ask Time:2009-11-19T03:39:21         Author:Sorskoot

Json Formatter

I've got this Silverlight Prism application that is using MVVM. The model calls a WCF service and a list of data is returned.

The ViewModel is bound to the View, so the ViewModel should have a List property.

Were should I keep data returned by a WCF service in MVVM?

Should the List property be calling into the Model using its getter? Where the model has a ReturnListOfData() method that returns the data stored in the model.

Or does the ViewModel stores the data after the Model is done with calling the server?


This is a follow up on Where to put the calls to WCF or other webservices in MVVM?

Author:Sorskoot,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/1758511/where-should-the-data-be-stored-in-mvvm
Anderson Imes :

Generally if I need to keep the Model objects around (I consider most things coming back from a WCF service a Model object) I will store it in my ViewModel in a \"Model\" property.\n\nI've seen people go so far as to create a standard Model property on their base ViewModel type, like this (I don't do this, but it's nice):\n\npublic class ViewModel<ModelType> : INotifyPropertyChanged ...\n{\n //Model Property\n public ModelType Model\n {\n ...\n }\n}\n\n\nIt's really up to you. Keeping them as close to their related ViewModels is probably the thing to take away here.",
2009-11-18T19:58:11
yy