Problem binding DataGridComboBoxColumn.ItemsSource

The columns in the datagrid don’t have a datacontext, as they are never added to the visual tree. sound a bit weird but have a look at vince’s blog, its got a good example of the visual layout. once the grid is drawn the cells have a data context and you can set the combo boxes items source in them using normal bindings (not static resources..)

You can access the combo box items source as such:

<dg:DataGridComboBoxColumn>
   <dg:DataGridComboBoxColumn.EditingElementStyle>
      <Style TargetType="ComboBox">
         <Setter Property="ItemsSource" Value="{Binding Path=MyBindingPath}" />
      </Style>
   </dg:DataGridComboBoxColumn.EditingElementStyle>
</dg:DataGridComboBoxColumn>

Have a look here and also here for some code. You will also need to set the items source for the non edting element as in this post

Leave a Comment