An online view containing two views of Caliburn.Micro?

I have a Windows WPF application in which I use Caliburn.Micro. The main window / viewmodel is handled by Caliburn.Micro. One of its buttons opens a new dialog box that uses another view-viewmodel.

In this dialog box, I have a container (list box and some filter controls) that I want to make into a reusable element to include it in other dialogs. To do this, I extracted from the dialog box and looked at the model of the corresponding code and created a new view mode and viewmodel. It all looks good.

The problem is that now in the dialog I have a dock with a large blank space in which I need a reusable item.

In the OnInitalize () view, I could create a multimode view control model, but I don’t know how to view it in the view pane of the dialog box.

To create a dialog box from the viewport of the main window, I use WindowManager (). ShowDialog () to display the viewmodel for the dialog, and Caliburn.Micro will take care of customizing the view. Is there a way that I can indicate in the XAML dialog that I want to embed a view for a reusable control and create a Caliburn for the corresponding view / viewmodel?

Or am I not mistaken about this?

+3
source share
1 answer

, , ContentControl , , , Caliburn.Micro , ContentControl . , ? - :

// 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>

, ( MyReusableControlViewModel) , .

+8

Source: https://habr.com/ru/post/1779654/


All Articles