caliburn.micro – Caliburn Micro:主shell VM中的“children”
发布时间:2020-12-15 21:14:23 所属栏目:安全 来源:网络整理
导读:我从Caliburn.micro开始,我有点困惑.假设我有一个带有2个窗格的UI,例如(这是一个假的样本)CustomersView和CustomerView,以及2个相应的VM,CustomersViewModel和CustomerViewModel. 现在,假设我想将两个窗格都包含在一个主shell中,它应该能够访问所有VM的数据
我从Caliburn.micro开始,我有点困惑.假设我有一个带有2个窗格的UI,例如(这是一个假的样本)CustomersView和CustomerView,以及2个相应的VM,CustomersViewModel和CustomerViewModel.
现在,假设我想将两个窗格都包含在一个主shell中,它应该能够访问所有VM的数据成员:例如 public class MainViewModel { private CustomerViewModel _vmCustomer; private CustomersViewModel _vmCustomers; ... } 由于视图模型是由CM创建的,我如何将主shell连接到它们的每个实例?或者这是一种错误的方法?我不需要在规范意义上的指挥,因为我没有像在MDI中那样激活或停用一组窗格:我有一个带有一些窗格的SDI UI,每个窗格都由它的VM支持,还有一个主shell应该是操纵他们.类似场景中的正确方法是什么? 解决方法
在MainView.xaml中添加两个ContentControl,并为它们指定与表示ViewModel的两个属性的名称相匹配的名称.
视图模型: public CustomerViewModel CustomerViewModel { get; set; } public CustomersViewModel CustomersViewModel { get; set; } 视图: <ContentControl x:Name="CustomerViewModel" /> <ContentControl x:Name="CustomersViewModel" /> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |