WPF: data binding to DataGridComboBoxColumn

This is what I want:

  • There is a list column bound to the ApplicationKey property of ClassA
  • The combo box is filled with ApplicationTokens from a static function.
  • ApplicationToken has property ApplicationName and ApplicationKey
  • When an item is selected from the drop-down list, the ClassA.ApplicationKey property is set to ApplicationToken.ApplicationKey on the selected item.

This is my current code that populates combobox but does not update ClassA.ApplicationKey.

<DataGridComboBoxColumn 
    Header="Application" 
    SelectedItemBinding="{Binding ApplicationKey, Converter={gui:DebugConverter}}" 
    SelectedValuePath="ApplicationKey" 
    DisplayMemberPath="ApplicationName" 
    ItemsSource="{Binding Source={x:Static app:ApplicationLookup.GetAllOrNone}}"/>
+5
source share
1 answer

SelectedValueBinding SelectedItemBinding SelectedValuePath.

<DataGridComboBoxColumn 
    Header="Application" 
    SelectedValueBinding="{Binding ApplicationKey}"
    SelectedValuePath="ApplicationKey" 
    DisplayMemberPath="ApplicationName" 
    ItemsSource="{Binding Source={x:Static app:ApplicationLookup.GetAllOrNone}}"/>
+6

All Articles