I have a WPF Datagrid populated with data from one SQL table using Entity Framework, is it possible to populate a combobox in the same Datagrid using data from a different table.
I have this code working
<DataGridTemplateColumn x:Name="reasonColumn" Header="Reason" Width="Auto">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox>
<ComboBoxItem Content="Supplier Quantity"/>
<ComboBoxItem Content="Supplier Price"/>
<ComboBoxItem Content="Supplier Numbers"/>
<ComboBoxItem Content="Supplier Codes"/>
<ComboBoxItem Content="Branch Quantity"/>
<ComboBoxItem Content="Branch Numbers"/>
<ComboBoxItem Content="Branch Codes"/>
<ComboBoxItem Content="IM Numbers"/>
<ComboBoxItem Content="Pop Prices"/>
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
But I would prefer it to be dynamically populated.
Thanks.
Yes, simply bind your
ComboBox.ItemsSourceto wherever your collection isFor example, this will bind a collection from your DataGrid’s DataContext:
As another example, this will bind to a static class containing your collection