I’m using Devexpress(latest version) + WPF with dotnet 7.
I have a GridControl
which have a few simple columns along side with a “Genres” column which is responsible for holding different genres of a “Game”.
initially I created an enum for holding the different types and I managed to bind the ItemsSource
to it using dxe:EnumItemsSource
.
my problem is that the data coming from the DB has predefined genres for the games so I have a List<Genre>
for each row which I’m failing to inserting into the GridControl
.
I tried with List<String>
instead of enums but that one also failed.
my lastest attempt:
<dxg:GridControl x:Name="GameGrid"
EnableSmartColumnsGeneration="True"
AutoGenerateColumns="AddNew"
MaxHeight="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type dx:ThemedWindow}}, Path=ActualWidth }">
<dxg:GridControl.View>
<dxg:TableView UseAnimationWhenExpanding="True"
AutoWidth="True"
NewItemRowPosition="Top"
ShowGroupPanel="False"
SearchPanelAllowFilter="True"
SearchPanelHighlightResults="True" />
</dxg:GridControl.View>
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="Id" />
<dxg:GridColumn FieldName="Name" />
<dxg:GridColumn FieldName="Genres">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<dxe:ComboBoxEdit
EditValue="{Binding Path=DataContext.Genres, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type dxg:GridColumn}} }">
<dxe:ComboBoxEdit.StyleSettings>
<dxe:TokenComboBoxStyleSettings />
</dxe:ComboBoxEdit.StyleSettings>
</dxe:ComboBoxEdit>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
</dxg:GridControl.Columns>
</dxg:GridControl>
(note that this snippet is not using enums but it would be nice if i could use them in this case)
so ultimately i want to load the data (coming from db) into the GridControl
including the “Genres” field.
and also being able to edit the items and adding new ones.
also AutoGenerating
Options did not help in this case as well.