Dialog view containing two Caliburn.Micro views?

不羁的心 提交于 2019-12-06 00:50:20

If you have a property on your dialog view model which is another view model type, and you add a ContentControl to your dialog view which is named the same as this property, then Caliburn.Micro will automatically inject the view which corresponds to your property view model type into the ContentControl placeholder, and bind that view model type to the view automatically too. Is this what you mean? Something like:

// Dialog View Model
private MyReusableControlViewModel myReuseableControl;
public MyReusableControlViewModel MyReuseableControl
{ 
   get { return this.myReuseableControl; }
   set { this.myReuseableControl = value;  NotifyOfPropertyChanged(...); }
}

// Dialog View Model Constructor
public DialogViewModel()
{
  this.MyReuseableControl = new MyReusableControlViewModel();
}

// Dialog View
<DockPanel>
  ...
  <ContentControl x:Name="MyReusableControl" />
</DockPanel>

Of course, ideally you would want to inject any dependencies of the dialog view model (in this case MyReusableControlViewModel) and work against abstractions inside the dialog view model, rather than concrete types.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!