View - 具有不同数据的ViewModel
我有一个称为选择器的视图,它本质上是两段文本,一个标题和另一个页面或视图的链接。在我的一次迭代中,我注意到这个视图可以制作成“视图部分”,并模仿我的应用程序的所有部分,以获得更好的整体 UI 体验。
我现在想知道,更改视图模型中的两个值以反映我想要安装此“视图部分”的应用程序的不同部分的最佳方法是什么。如果它进入模型,它们是否应该是值景色?
如果有帮助的话,我在我的应用程序中使用 MVVM Light 及其 WP7。
I have a view, called a selector, which is essentially two pieces of text, a heading and a link to another page or view. During one of my iterations I noticed that this view could be made into a "view part" and mimicked all around my app for a better overall UI experience.
I now wonder, what would be the best way to change the two values in the View Model to reflect the different parts of the app I want to install this "view part" in. Should it reach into the model, should they be values on the view?
I use MVVM Light in my application and its WP7 if that helps.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我想我找到了一个很好的干净的方法来做到这一点。将我的视图模型 ID 属性作为“活动视图 ID”绑定到我的模型。该属性将包含打开的视图的 ID(视图部件始终驻留在视图内),视图部件只需读取该值,然后根据它从模型中提取适当的数据。
Ok I think I found a nice clean way to do this. Have my views models ID property bound to my model as the "active view id". This property will contain the ID of the View that is open (the view parts reside inside a view at all times), the view part simply reads this value and then pulls up the appropriate data from the model based on it.