views:

99

answers:

1

This is what I want:

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

This is my current code, which populates the combobox but doesn't update ClassA.ApplicationKey.

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

Use SelectedValueBinding instead of SelectedItemBinding when using SelectedValuePath.

Working example

<DataGridComboBoxColumn 
    Header="Application" 
    SelectedValueBinding="{Binding ApplicationKey}"
    SelectedValuePath="ApplicationKey" 
    DisplayMemberPath="ApplicationName" 
    ItemsSource="{Binding Source={x:Static app:ApplicationLookup.GetAllOrNone}}"/>
Wallstreet Programmer
Yep, that was it. Thank you.
Jonathan Allen