I have been leveraging Entity Framework (EF) to build Entities from the world famous Northwind Product and Categories Table.
Steps
1. I create the Product and Category EF objects from the Northwind database.
2. I use drag and drop from the Data Source Window to create a WPF DataGrid for the Products Table. This creates CollectionViewSource for the Products Table and puts a reference in the MainWindow.xaml Resources.
3. I do the same (step 2) for the Category Table. But in the case of the Category Table I delete the WPF DataGrid created for the Category Table. The purpose of this step is to crated the CollectionViewSource for the Category Table.
4. I update the code behind to fully populate the CollectionViewSource for both the Product and Categories Table.
5. I modify the columns created for the Products DataGrid that was created in step 2. This DataGrid is reduced to 2 columns: a DataGridTextColumn bound to ProductName and a DataGridComboBox used to select Category. The DataGridComboBox is written from scratch. Compile and Run - success. I can change the Category.
6. I comment out the WPF DataGrid
7. I try to create a functionally equivalent Syncfusion SfDataGrid, but I cannot get the GridComboBoxColumn to work. See Below. Nothing shows in the combo box. If I change the DisplayMemberPath to "CategoryID", it show that value.
<!--<DataGrid x:Name="productDataGrid"
RowDetailsVisibilityMode="VisibleWhenSelected"
Margin="43,32,36,163" ItemsSource="{Binding}"
EnableRowVirtualization="True"
AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn x:Name="productNameColumn"
Header="Product" Binding="{Binding ProductName}"/>
<DataGridComboBoxColumn x:Name="categoryColumn"
Header="Category" ItemsSource="{Binding Source={StaticResource
categoryViewSource}}"
SelectedValuePath="CategoryID" SelectedValueBinding="{Binding
CategoryID, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
DisplayMemberPath="CategoryName" />
</DataGrid.Columns>
</DataGrid>-->
<Syncfusion:SfDataGrid x:Name="productDataGrid"
Margin="43,32,36,163" ItemsSource="{Binding}"
AutoGenerateColumns="False" AllowEditing="True">
<Syncfusion:SfDataGrid.Columns>
<Syncfusion:GridTextColumn x:Name="productNameColumn" HeaderText="Product"
MappingName="ProductName"/>
<Syncfusion:GridComboBoxColumn x:Name="categoryColumn"
HeaderText="Category"
ItemsSource="{Binding Path=Category, Source={StaticResource categoryViewSource},
Mode=TwoWay}"
MappingName="CategoryName" AllowEditing="True" />
</Syncfusion:SfDataGrid.Columns>
</Syncfusion:SfDataGrid>
Thank You for the help
Hi Srinivasan,I tried both of your suggestions to no avail. I changed the XAML in the SfDataGrid that I sent in opening post. The DataGrid works - but cannot figure out how to get SfDataGrid to work.<Grid DataContext="{StaticResource productViewSource}">
<StackPanel>
<DataGrid x:Name="productDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" Margin="10"
ItemsSource="{Binding}" EnableRowVirtualization="True" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn x:Name="productNameColumn" Header="Product"
Binding="{Binding ProductName}" Width="Auto"/>
<DataGridComboBoxColumn x:Name="categoryColumn" Header="Category"
ItemsSource="{Binding Source={StaticResource categoryViewSource}}"
SelectedValuePath="CategoryID" SelectedValueBinding="{Binding CategoryID,
UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
DisplayMemberPath="CategoryName" />
</DataGrid.Columns>
</DataGrid><Syncfusion:SfDataGrid x:Name="productDataGrid1" Margin="10" ItemsSource="{Binding}"
AutoGenerateColumns="False" AllowEditing="True" AllowResizingColumns="True" ColumnSizer="Auto">
<Syncfusion:SfDataGrid.Columns>
<Syncfusion:GridTextColumn x:Name="productNameColumn1" HeaderText="Product"
DisplayBinding="{Binding Path=ProductName}" AllowResizing="True" />
<Syncfusion:GridComboBoxColumn x:Name="categoryColumn1" HeaderText="Category"
ItemsSource="{Binding Source={StaticResource productViewSource}}"
MappingName="CategoryID" AllowEditing="True"
DisplayMemberPath="CategoryName"
/>
</Syncfusion:SfDataGrid.Columns>
</Syncfusion:SfDataGrid>
</StackPanel>
</Grid>I think the main SfDataGrid problem I am grappling with is the ItemSource Binding Path required by Syncfusion. I cannot figure out what to use as a Path for the CollectionViewSource. The example you sent was for an Observable Collection. By trial and error, I cannot figure out what to do.In my XAML above for the SfDataGrid, where I do not use any Item Source Binding Path, the combobox columns comes up blank yet I can select from the pull down Category Names in the combo box. The combo box selection does not stick and reverts to blank when I exit. If I use any value (and I have tried several) as the Binding Path I regress & cannot even see Category Names in the pull down.As I stated earlier I use EF and Drag & Drop from DataSource window to build my CollectionViewSource objects & references to it.
Ok, I have this working using the below However the column MyHeaderText, always shows blank (nothing, empty), until I click on the cell into edit mode. When it goes to edit mode it brings up the ComboBox and the combobox works. However, when i then move off the cell, the cell becomes blank again.
Why does this happen? I downloaded the example attached to the this same thread earlier, and it doesn't happen in that example. There are a few other people who have mentioned this in other posts. But I have never found a resolution
WORKING XMAL
<syncfusion:GridComboBoxColumn
x:Name="FTELOCComboBox" //binding is set in the code behind to this object as --> FTELOCComboBox.ItemsSource = FTE_LocationDataTable.DefaultView; (and FTE_LocationDataTable is a DataTable)
DisplayMemberPath="Country"
HeaderText="MyHeaderText"
MappingName="L_ID"
SelectedValuePath="ID