MVVM 如何:嵌入引用其虚拟机的视图?
我有一个代表主窗口的主视图,其中有区域和控件。
我希望每个领域都通过另一个虚拟机来强调。
如何声明 XAML,以及如何根据父视图的内容引用每个嵌套视图的 DataContext?
I have one main View that represents the main window, in that I have areas and controls.
I want each of these areas to be underlined by anoter VM.
How do I declare the XAML, and how do I refer the DataContext of each nested view according to the parent View's content?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
主页可以有多个代表区域的导航框架。框架中导航到的每个页面都可以有自己的视图模型。设置子页面的数据上下文与设置主页的数据上下文没有什么不同。要更改框架中的页面,您可以调用frame.navigate,传递要加载的页面的uri。
The main page can have multiple navigation frames that represent the areas. Each page navigated to in a frame can have it's own view model. Setting the data context for the child pages is no different than setting the data context for the main page. To change a page in a frame you call frame.navigate passing the uri of the page you want to load.