我如何可以通过使用的NavigationService对象的ViewModels? [英] How can I pass objects to ViewModels using NavigationService?

查看:154
本文介绍了我如何可以通过使用的NavigationService对象的ViewModels?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的这个项目是一个基于WPF应用程序桌面。我已经实现其中的MVVM模式。另外我使用统一的IoC和它Repository模式。

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.

我有一个主细节类型场景的一个问题。我导航到详细信息页面(我已经使用的IoC揭露的NavigationService在视图模型),但我不知道我怎样才能在EmployeeDetails视图模型的雇员没有打破MVVM模式。我不想写在后面的code什么。

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.

问候。

推荐答案

通常情况下,通过公开的属性 CurrentEmployee 实现这个EmployeeMasterViewModel 。此属性的数据绑定到主列表中当前所选的项目。
然后,您绑定的详细信息页面的控制,以 CurrentEmployee 的属性。

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.

这篇关于我如何可以通过使用的NavigationService对象的ViewModels?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆