如果我有 aMultiPresenter
并且我正在使用 aListBox
来显示Presenters
它所托管的内容,我如何让 Caliburn 发现和绑定项目的视图和视图模型?
例如,如果我有一个看起来像这样的简单视图:
<UserControl x:Class="MyProject.Views.CarView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<ListBox ItemsSource="{Binding Parts}" />
</Grid>
</UserControl>
绑定到CarViewModel
:
public class CarViewModel : MultiPresenter
{
public BindableCollection<IPartViewModel> Parts { get; }
}
并且该Parts
集合包含实现IPresenter
并具有相应视图的各种对象,例如WheelViewModel
andWheelView
和EngineViewModel
and EngineView
。
我希望 Caliburn 使用视图策略为我解析视图。这可能吗?在这种情况下,我需要做什么才能正确设置演示者的层次结构?