tags:

views:

56

answers:

0

I have a datagrid with two DataGridComboBoxColumn. The DataContext for the datagrid is set in the code behind as the DefaultView of a DataTable. This includes the two columns I want the combo boxes for so I can store the selected value in the DataTable and ultimately write it back to the database. I want to have the ComboBoxColumn display the selected value from the DataContext when not editing, but while editing, I want a drop down with all the possibilities listed.

What I've got working is the EditingElementStyle, which properly displays the options. But the ElementStyle displays nothing. Somehow I'm not getting the binding correct for the ElementStyle, as the data isn't displaying when loaded, and any edits aren't being displayed either.

Below is the XAML for one of the columns. The StaticResource responseDataProvider is an ObjectDatProvider that references a nested class the provides an ObservableCollection of a custom class.

<my:DataGridComboBoxColumn x:Name="colResponse" x:FieldModifier="public" SelectedValueBinding="{Binding Response}" Header="Response" Width="75" IsReadOnly="False">
   <my:DataGridComboBoxColumn.ElementStyle>
       <Style TargetType="ComboBox">
           <Setter Property="ItemsSource" Value="{Binding Response}" />
       </Style>
   </my:DataGridComboBoxColumn.ElementStyle>
   <my:DataGridComboBoxColumn.EditingElementStyle>
       <Style TargetType="ComboBox">
           <Setter Property="ItemsSource" Value="{Binding Source={StaticResource responseDataProvider}}" />
           <Setter Property="DisplayMemberPath" Value="choice" />
           <Setter Property="SelectedValuePath" Value="choice" />
       </Style>
   </my:DataGridComboBoxColumn.EditingElementStyle>
</my:DataGridComboBoxColumn>

What detail am I missing? Thanks in advance.