Posted By

dck11 on 11/03/11


Tagged

DataGrid WPF comboboxcolumn itemssource


Versions (?)

WPF:DataGrid:ComboBoxColumn ItemsSource


 / Published in: C#
 

URL: http://stackoverflow.com/questions/5409259/binding-itemssource-of-a-comboboxcolumn-in-wpf-datagrid

  1. <DataGridComboBoxColumn
  2. SelectedValueBinding="{Binding CompanyID}"
  3. DisplayMemberPath="Name"
  4. SelectedValuePath="ID">
  5.  
  6. <DataGridComboBoxColumn.ElementStyle>
  7. <Style TargetType="{x:Type ComboBox}">
  8. <Setter Property="ItemsSource" Value="{Binding Path=DataContext.CompanyItems, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" />
  9. </Style>
  10. </DataGridComboBoxColumn.ElementStyle>
  11. <DataGridComboBoxColumn.EditingElementStyle>
  12. <Style TargetType="{x:Type ComboBox}">
  13. <Setter Property="ItemsSource" Value="{Binding Path=DataContext.CompanyItems, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" />
  14. </Style>
  15. </DataGridComboBoxColumn.EditingElementStyle>
  16. </DataGridComboBoxColumn>

Report this snippet  

You need to login to post a comment.