I’m having some issues with a GridViewComboBoxColumn. I am binding a List of items to populate the combo box. My overall data structure is as follows. My grid’s ItemsSource is a List of ActionListInfo items. Each ActionListInfo contains: string ActionName, int SequenceNumber, DrillDownSource DDSource, List<DrillDownSource> PossibleSources. Each instance of DrillDownSource contains: int Id, string Name. Note that the list of PossibleSources is different between each ActionListInfo and can change dynamically.
My grid consists of a column displaying each ActionListInfo’s name, a column displaying their sequence #, and their selected DrillDownSource (the combo box column). First off, the combo box does not display anything until it is clicked. The combo box then correctly displays the possible options for that row’s DrillDownSource. Selecting one of these choices correctly fires the DDSource_Changed listener and even sets the DDSource of that row’s ActionListInfo properly (I know this because I’ve added a test column that is bound to each ActionListInfo’s DDSource property and it updates correctly after selecting a choice).
The problem I’m having is that even after a selection is made, once the user clicks away from the combo box (leaving edit mode I suppose), the cell goes blank. I know the value was selected, but no value is displayed in the comb box cell. It’s just empty. It’s worth noting that when my listener DDSource_Changed is called, it does its own rebinding of the grid. It clears the grid’s ItemsSource and then sets it to the list of ActionListInfo items (one of which has a newly defined DDSource). Please look at the included pictures in order to better understand.
Is there any way to set the SelectedValue property of the combo box in the column? I would like to set it to the DDSource of each ActionListInfo (this DDSource is updated correctly each time the combo box is used). If not, please tell me what I might be doing wrong. Is there a specific binding similar to SelectedValueMemberPath that is used to determine which choice to display? My binding for this particular column is shown below.
Please note that I do all of my work in the code. I do not use any XAML. Also, sorry for the wall of text.
GridViewComboBoxColumn ddSource = new GridViewComboBoxColumn();
ddSource.ItemsSourceBinding = new System.Windows.Data.Binding("PossibleSources");
ddSource.DataMemberBinding = new System.Windows.Data.Binding("Id");
ddSource.Header = "Drill-Down Source";
ddSource.DisplayMemberPath = "Name";
ddSource.SelectedValueMemberPath = "Id";
ddSource.IsReadOnly = false;
ddSource.EditTriggers = Telerik.Windows.Controls.GridView.GridViewEditTriggers.CellClick;
_grid.AddHandler(RadComboBox.SelectionChangedEvent, new Telerik.Windows.Controls.SelectionChangedEventHandler(DDSource_Changed));
_grid.ItemsSource = _actions;