What I really need is a really good walkthrough of how to use a celleditor in a DataGrid bound to a database...
But, at the moment, I have two immediate problems... Eternal gratefulness if anyone can help or point me in the right direction.
I have a DataGrid populated with "Modules." A "Module" can be assigned to a "Category" (but it is not required). The DataGrid displays the Category to which a Module is assigned. When I Edit the Module row, I want the user to be able to select from a combobox of Categories populated from a Database.
Currently, if a Module has no Category, I can click on the empty cell, which will display the correctly populated combobox. When I select a value fromt he ComboBox, the CB disappears (reverst to "View?") but there is no value present in the DataGrid row.
The second issue is that, when a Module already has an assigned Category, the Category shows properly in the DataGrid view, but if I click on the cell in an attempt to edit it (i.e. display the combobox), the 0-index row becomes selected and no combobox is ever displayed.
Any help at all... much much appreciated. Thank you!
CODE:
<Grid Name="Grid1">
<Grid.Resources>
<xcdg:DataGridCollectionViewSource EditCommitted="dgcs_EditCommitted" x:Key="ID" Source="{Binding Source={x:Static Application.Current},Path=Modules}"/>
</Grid.Resources>
<xcdg:DataGridControl x:Name="CategoriesGrid" ItemsSource="{Binding Source={StaticResource ID}}">
<xcdg:DataGridControl.Columns>
<xcdg:Column FieldName="ID" Title="ID" ReadOnly="True" Visible="False" IsMainColumn="True"></xcdg:Column>
<xcdg:Column FieldName="CatName" Title="Category Name">
<xcdg:Column.CellEditor>
<xcdg:CellEditor>
<xcdg:CellEditor.EditTemplate>
<DataTemplate>
<ComboBox BorderThickness="0" MinHeight="22" SelectedValue="{xcdg:CellEditorBinding}" ItemsSource="{Binding Source={x:Static Application.Current},Path=Categories}" SelectedValuePath="DisplayName" DisplayMemberPath="DisplayName" VerticalContentAlignment="Top" FocusVisualStyle="{x:Null}">
<ComboBox.Resources>
<Style TargetType="Popup">
<Setter Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" />
</Style>
</ComboBox.Resources>
</ComboBox>
</DataTemplate>
</xcdg:CellEditor.EditTemplate>
</xcdg:CellEditor>
</xcdg:Column.CellEditor>
</xcdg:Column>
<xcdg:Column FieldName="DisplayName" Title="Module Name" />
<xcdg:Column FieldName="OrderVal" Title="Display Order" />
<xcdg:Column FieldName="CatOrder" Visible="False" />
<xcdg:Column FieldName="xtID" Title="Express Train ID" ReadOnly="True" />
</xcdg:DataGridControl.Columns>
<xcdg:DataGridControl.View>
<xcdg:TableView ColumnStretchMode="All" UseDefaultHeadersFooters="False">
<xcdg:TableView.FixedHeaders>
<DataTemplate>
<xcdg:HierarchicalGroupByControl xcdg:TableView.CanScrollHorizontally="False" />
</DataTemplate>
<DataTemplate>
<xcdg:ColumnManagerRow />
</DataTemplate>
</xcdg:TableView.FixedHeaders>
</xcdg:TableView>
</xcdg:DataGridControl.View>
</xcdg:DataGridControl>
</Grid>