Thre’s something I don’t get. If i have for instance a profile.xaml page and I have a ProfileViewModel with a user instance. How do I tell the ProfileViewModel with a User property to load user with an id that I want?
I mean : How do I pass a userid to the profileviewmodel when I click a button in another page to open that page?
For Instance
Userlist.xaml has a list of users. One is clicked and an instance of Profile.Xaml is loaded, but how do I pass the userId onto the viewmodel? Won’t i need some dependencyproperty in profile.xaml and then pass it on?
Please tell me if this makes sense to you 🙂
You should consider binding your list of users in Userlist.xaml to a collection of ProfileViewModel instances, then you can just provide the specific ProfileViewModel to the profile.xaml.
In this example, your Userlist.xaml would include:
And your UserlistViewModel would include:
As Reed mentioned above, one way to pass the user profile view model to your other page would be MVVM Light Toolkit’s messaging.