I have some problem to access the Window's DataContext from within a DataGrid.
The DataGrid is bound to a IBindingList:
public IBindingList Items{ get; set; }
private void initItems()
{
//ItemFactory is a Linq2SQL Context, Items is the view of availabe Items
this.Items = this.ItemFactory.Items.GetNewBindingList();
}
From within my xaml I try to get those data to fill a ComboBox:
<DataGridComboBoxColumn Header="Typ"
DisplayMemberPath="Description"
SelectedValuePath="ItemID"
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Mode=OneWay, Path=DataContext.Items, UpdateSourceTrigger=PropertyChanged}" />
But it doesn't work. I tried out many variants already. The ComboBox gets not populated.
Any help greatly appreciated!
Note:
The following ComboBox in the same Window does work:
<ComboBox x:Name="workingCombo" ItemsSource="{Binding Path=Items}" DisplayMemberPath="Description" SelectedValuePath="ItemID" />