MVVM - 具有导航和可混合性的主/详细场景
我将从我想要的开始,这样可能更容易理解:
- 我有一个页面(Master.xaml),其中有一个 PersonViewModel 列表框。
- 当用户从列表框中选择 PersonViewModel 时,我想导航到所选 PersonViewModel 的详细信息 (Details.xaml) 页面。
- 详细信息页面做了一些额外的繁重工作,我只想在用户导航到该页面时完成这些工作。 (我不想在主列表框的每个 PersonViewModel 中加载太多内容)
那么你们如何通过导航处理主/详细场景,同时保持“可混合性”?
过去一周我一直在兜圈子。对于应该很常见的事情似乎没有干净的解决方案?
I'll start off with what I want so it may be simpler to understand:
- I have a Page (Master.xaml) that has has a listbox of PersonViewModel.
- When the user selects a PersonViewModel from the listbox, I want to Navigate to a details (Details.xaml) page of the selected PersonViewModel.
- The details page does some extra heavy lifting that I only want done once the user navigates to the page. (I don't want too much stuff loaded in each PersonViewModel of the master listbox)
So how do you guys handle master/detail scenarios with navigation while maintaining "blendability"?
I've been turing in circles for the past week. there seems to be no clean solution for something that should be quite common?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了一个我非常满意的解决方案。当 IsInDesignTool 为 true 时,我会调用命令来伪造用户交互(例如:PlayCommand),因此当我看到混合中的设计区域时,就好像用户已经触发了该命令。
Found a solution that i'm pretty happy with. When IsInDesignTool is true, I call commands to fake user interactions (Ex: PlayCommand) so when I see the Design area in blend, it's as if the user already fired the command.