【发布时间】:2009-11-27 09:21:28
【问题描述】:
如果我有一个 MultiPresenter 并且我使用 ListBox 来显示它所托管的 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 和 WheelView,以及 EngineViewModel 和 EngineView。
我希望 Caliburn 使用视图策略为我解析视图。这可能吗?在这种情况下,我需要怎么做才能正确设置演示者的层次结构?
【问题讨论】:
标签: wpf mvvm itemscontrol caliburn