How can I pass objects to ViewModels using NavigationService?
The project I am working on is a desktop based WPF application. I have implemented the MVVM pattern in it. Also I am using Unity IoC and the Repository Pattern in it.
I have a problem in a master details type scenario. I navigate to the details Page(I have used IoC to expose the NavigationService in the ViewModel) but I 开发者_运维技巧dont know how can I get the employeeID in the EmployeeDetails ViewModel without breaking the MVVM pattern. I don't want to write anything in code behind.
Any pointers will be very helpful.
Regards.
Normally, you achieve this by exposing a property CurrentEmployee
in your EmployeeMasterViewModel
. This property is data bound to the currently selected item in the master list.
You then bind the controls of the details page to the properties of CurrentEmployee
.
精彩评论