I have this columns in datagrid wpf
<DataGrid.Columns>
<DataGridComboBoxColumn SelectedItemBinding="{Binding Path=ProductId}" DisplayMemberPath="Name" SelectedValuePath="Id" />
<DataGridTextColumn Binding="{Binding Path=StorageAmount}" Width="*" Header="Со склада" />
<DataGridTextColumn Binding="{Binding Path=Trade1Amount}" Width="*" Header="С точки 1" />
<DataGridTextColumn Binding="{Binding Path=Trade2Amount}" Width="*" Header="С точки 2" />
<DataGridTextColumn Binding="{Binding Path=TotalAmount}" Width="*" Header="Всего" FontWeight="Bold" />
</DataGrid.Columns>
How can I bind DataGridComboBoxColumn programmatically from code, not from xaml? I can’t define Name to DataGridComboBoxColumn so I can’t access from code in order to fill DataContext of this Combobox
Use the x:-namespace with the Name-attribute. This will do what you’re looking for: