Editing DataGridComboBoxColumn

Jan 18, 2010 at 12:34 PM

I am working through the hands on lab here http://windowsclient.net/downloads/folders/hands-on-labs/entry76491.aspx using the original WPFtoolkit dll and the DataGridComboBoxColumn editing is not working as expected. When the cell looses focus after an edit nothing is displayed. I do not get this behaviour when selecting from an existing item in the combo box. The data change is persisted (On closing the application and re-opening it the change is visible). The edited item is visible in edit mode but not in normal viewing mode. Below is the xaml snippet the datagrid has its ItemsSource set to "{Binding}". This is a CheckRegisterCollection which subclasses an ObservableCollection of RegisterTransactions

<dg:DataGridComboBoxColumn Header="Memo" Width="*"
                           ItemsSource="{Binding Source={x:Static Data:CheckBook.Descriptions}, Mode=OneWay}"
                           TextBinding="{Binding Memo}">
                        <Style TargetType="ComboBox">
                            <Setter Property="IsEditable" Value="True" />

CheckBook.Descriptions returns an IEnumerable of strings. The code is exactly as per the walkthrough with one minor change: on the RegisterTransaction class I altered the Memo property setter from OnPropertyChanged("Description") to OnPropertyChanged("Memo").

How can DataGridComboBoxColumn edits be displayed?

I tried SelectedValueBinding and playing around with adding DataGridComboBoxColumn.ElementStyle but could not get either of these to work. In normal view mode the items are shown in a TextBlock within a DataGridTextBlock but there does not seem to be an easy way to access these. I think the comboBox drop down is not part of the dataGrids visual tree so the selected and newly edited item is not being communicate to the non edit view within the column and therefore cannot be displayed.

The same behaviour can be seen with the June 2009 WPFToolkit.

(Apologies if this has been asked before but I looked at the other similar posts first and could not get this to work in this example)

Any help is much appreciated - thanks