views:

41

answers:

1

Look how odd is the following scenario:

<DataGrid.Columns>
  <!--Doesn't work-->
  <DataGridComboBoxColumn
    Header="Vendor"
    ItemsSource="{Binding Vendors}"
    SelectedItemBinding="{Binding Vendor, 
    UpdateSourceTrigger=PropertyChanged}" 
    DisplayMemberPath="Contact.Title"/>

  <!--Works-->
  <DataGridTemplateColumn Header="Vendor">
    <DataGridTemplateColumn.CellTemplate>
      <DataTemplate>
        <TextBlock DataContext="{Binding Vendor}"
          Text="{Binding Contact.Title}"/>
      </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
    <DataGridTemplateColumn.CellEditingTemplate>
      <DataTemplate>
        <ComboBox ItemsSource="{Binding Vendors}"
          SelectedItem="{Binding Vendor, UpdateSourceTrigger=PropertyChanged}"
          DisplayMemberPath="Contact.Title"/>
      </DataTemplate>
    </DataGridTemplateColumn.CellEditingTemplate>
  </DataGridTemplateColumn>
</DataGrid.Columns>
A: 

I posted a connection to Microsft.

Microsoft explained to me, that since the common use of the ItemsSource property of the DataGridComboBoxColumn is to bind it to StaticResource or to any other resource that is not different for each row, it's evaluated with the DataGrid once, not per row, so in order to update the ItemsSource for each row individually, a DataGridTemplateColumn and an inner ComboBox, which this one's ItemsSource does bind per row.

Shimmy