I'd like to reuse a view for 2 different viewmodels, in my example MyEntityEditViewModel
and MyEntityCreateViewModel
. The view is basically just a form with a Save
button, so pretty common layout.
I created both view models along with a parent view / view model (MyEntitySummaryViewModel
) and now I'd like to define the form view using a ContentControl
.
Summary view:
<ContentControl x:Name="ActiveItem" cal:View.Model="{Binding ActiveItem}" cal:View.Context="MyEntityDetailView" />
MyEntitySummaryViewModel:
public MyEntity SelectedEntity {
get { return _selectedEntity; }
set {
_selectedEntity = value;
NotifyOfPropertyChange();
ActivateItem(new MyEntityEditViewModel(_selectedEntitity));
}
}
public void Create() {
ActivateItem(new MyEntityCreateViewModel(new MyEntity()));
}
My problem is now that Caliburn tries to locate a 'MyEntityEditView
' due to it's view locating conventions, even if I strictly defined the context of the ContentControl
as a custom view. Is there a way around this? Or am I doing something completely wrong here?