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