I am confused by what should be a model or a model of representation and what they should be called.
For simplicity, I will leave INotifyPropertyChange out of it.
The following class is explicitly a model:
class CountryModel { public string Name { get; set; } public string Location { get; set; } }
Basically, you see on the Internet that the presentation model will be defined as follows:
class CountryViewModel { public CountryViewModel {
Why, for example, there is no Countries model, i.e. CountriesModel ? Why is this considered a presentation model?
Should it be technically? If we have another class for the view model, then?
class CountryViewModel { private ObservableCollection<CountryModel> _countries = new ....; public CountryViewModel { } public ObservableCollection<CountryModel> Countries { private get { return _countries ?? _countries = LoadCountries(); } set { _countries = value; } } private ObservableCollection<CountryModel> LoadCountries() { ObservableCollection<CountryModel> countries = new ...; foreach (CountryModel country in CountriesModel) { countries.add(country); } return countries; } }
Is this the foregoing? I just donβt understand why this looks like a standard, and why you would call CountriesViewModel , when I should have CountriesModel , and CountryViewModel should be created to access data from CountriesModel .
Also, if you stick to what's on the Internet, i.e. CountryModel and CountryViewModel , which contains an observable collection of CountryModel , how will you deal with countries containing each list of cities? I would have CityModel as POCO, and then for a list of cities, I would create a CityViewModel that has an observable collection of CityModel .
But then what? Am I supposed to make CityViewModel part of my CountryModel ? This does not seem right! Maybe this is so, and someone can clarify this. Here I am even more confused since I created a CountryModel with Name , Location properties and a property of type List<CityModel> , but how to correctly represent it in MVVM?
How to determine this correctly? Especially in the part where you have a list of objects, and each of these objects contains a different list. What model, view model, and how do I process the list inside my model?