I'm building most of my application with Xamarin.Forms and MVVM Light. I searched around the web for MVVM best practices, but i couldn't find a suitable answer.
Here's the context:
- I have a master page and his viewmodel. The viewmodel call a web service and load all items in an observable collection.
- When i click an item in the list (binded listview), i want to go to the detail page for this selected item.
Now here are my question :
- 1) Should my observablecollection contains viewmodels and then i pass the selected one to the detail page ?
- 2) Should I pass an ID to the detail page and then build initialize my detail viewmodel through a service using the id parameter ?
- 3) Is there any performances drawbacks ? I mean:
- In case 1, what if my listview display only 2 properties and my details pages 50 properties, why should i have a viewmodel with 50 properties in my listview, when i'm displaying only 2.
- In case 2, assuming i have a specific listview viewmodel with only 2 field, then i pass the id, i probably make a 2nd call to the webservice to get the details information and initialize my detail viewmodel, where i could only make 1 and get everything on the first call.
I hope it's clear enough,
If i'm missing something or you have another way to achieve this, fill free to tell me