0
我有一个用户控件中的网格放置在具有2个集合的窗口中。无法访问datacontext的属性
我正在寻找一种方法从我的网格中获取到集合2。
我已经尝试了几件事情:
ItemsSource="{Binding DataContext.Bicycles, RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type CollectionContainer}}}" />
和
<ComboBox Grid.Column="1" Grid.Row="2" ItemsSource="{Binding RelativeSource=
{RelativeSource FindAncestor, AncestorType=Window, AncestorLevel=1},
Path=DataContext.Bicycles}" DisplayMemberPath="Height" />
和
<ComboBox Grid.Column="1" Grid.Row="2" ItemsSource="{Binding RelativeSource=
{RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Companies}"
/>
但每次我的组合框结束了空
没有,真正的错误是,我放下X:类型窗口,这是不是这样的,这是因为使用棱镜,一切都是一个用户控制。这和事实我应该已经上升了两个层次。 – DerMeister 2011-04-18 15:06:02