What is the correct way to handle MVVM with Prism and content views?
I'm trying to port this Xamarin application to Prism (this contentview, and this code) and am unsure of the right way to do this.
Do I
- Create a ViewModel and then register them in my
IContainerRegistry
? - Does the parent (outer) ViewModel contain the object that will be bound to?
- Can the parent view model communicate with the ContentView?
You don't need a viewmodel defined for the ContentView.
Yes the underlying viewmodel holds the data for the item in question hence the BindableProperty in the code behind for the ProfileStripView.
It is a user control doesn't mean you can't have changes cross over between the "user control" which is what the ContentView is basically serving as in this case. In that case of data changes the properties would need backers for changes and the bindings setup accordingly to allow for changes.
All contentview really does is give the ability to get cleaner appearance to an already cluttered screen in a reusable package which is setup for 1 type in this case Athlete. They are equivalent to
Fragments in Android
and inWindows UWP/WPF
they areContentControls