Question : combobox in datagrid wpf
Answered by : sore-stork-9w031io2mq2e
<DataGridComboBoxColumn SelectedValueBinding="{Binding CompanyID}" DisplayMemberPath="Name" SelectedValuePath="ID"> <DataGridComboBoxColumn.ElementStyle> <Style TargetType="{x:Type ComboBox}"> <Setter Property="ItemsSource" Value="{Binding Path=DataContext.CompanyItems, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" /> </Style> </DataGridComboBoxColumn.ElementStyle> <DataGridComboBoxColumn.EditingElementStyle> <Style TargetType="{x:Type ComboBox}"> <Setter Property="ItemsSource" Value="{Binding Path=DataContext.CompanyItems, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" /> </Style> </DataGridComboBoxColumn.EditingElementStyle>
</DataGridComboBoxColumn>
Source : https://stackoverflow.com/questions/5409259/binding-itemssource-of-a-comboboxcolumn-in-wpf-datagrid | Last Update : Mon, 23 Aug 21
Question : binding combobox header datagrid wpf
Answered by : sore-stork-9w031io2mq2e
"{Binding DataContext.oTran, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}"
Source : | Last Update : Wed, 29 Dec 21