I have some problem accessing a Window DataContext from a DataGrid.
DataGrid bound to IBindingList:
public IBindingList Items{ get; set; }
private void initItems()
{
this.Items = this.ItemFactory.Items.GetNewBindingList();
}
From my xaml, I'm trying to get this data to populate 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 that will not work. I have already tried many options. ComboBox is not filling.
Any help is much appreciated!
Note:
The following ComboBox in the same window works:
<ComboBox x:Name="workingCombo" ItemsSource="{Binding Path=Items}" DisplayMemberPath="Description" SelectedValuePath="ItemID" />
source
share