我尝试将ListBox.ItemsSource绑定到包含三个CollectionContainers的CompositeCollection。每个CollectionContainer都绑定到我的ViewModel中的ObservableCollection。
因为CompositeCollection不知道我的DataContext,所以我将Source设置为“Proxy”,它是一个知道我的DataContext的FrameworkElement。
<CollectionContainer Collection="{Binding DataContext.Dampings, Source={x:Reference Proxy}}" />
<CollectionContainer Collection="{Binding DataContext.Angles, Source={x:Reference Proxy}}" />
<CollectionContainer Collection="{Binding DataContext.Selectors, Source={x:Reference Proxy}}" />
这在运行时按预期工作,虽然它确实在设计时在DataContext上显示警告: 无法在“对象”类型的数据上下文中解析属性“DataContext”。
有没有办法解决这个设计时问题,因为重命名不会应用于我的Bindings,因为设计师无法正确解析它们?