Search code examples
wpfcomboboxbindingdatagriddatasource

WPF ComboBox/ComboBoxEdit in Datagrid/GridControl Row ItemsSource from outside row


i have a DevExpress ComboBoxEdit inside a GridControl. Afaik ComboBox inside a DataGridRow has the same problem.

EditValue is inside the row-object:

EditValue="{Binding Row.Selected}"

Thats ok.

Currently the ItemsSource = List of all possible options is also inside the row-object.

ItemsSource="{Binding Row.AllPossibilities}"

It works but i don't like to clutter the object too much - it has then to contain lists of every possible option for most of the properties.

Thats why i what to chance the ItemsSource to be in the DataContext of the WPF UserControl instead the DataContext of the GridControl inside the UserControl.

I tried setting the ItemsSource with Path and name in the UserControl DataContext but got XAML-Bindingerror that the Property is not found in object of type "EditGridCellData"

Is that even possible? If yes, how?


Solution

  • Found a solution:

    ItemsSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}},Path=AllPossibilities,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"