I have data items with the following structure
I add the collection of the items to a XamDataGrid. It displays the columns as I like (IdRelated-Text1, IdRelated-Text2 and other properties). I disabled the auto generation of the columns. Now I like to add a MultiColumnComboBox to the cells of the two IdRelated-Text columns. The multi column combobox should display the two IdRelated-Text as columns in the drop down list of the combobox. When I select an item, it should change the value of the Id column (which is hidden) and not the IdRelated-Text columns directly.
What is the best practice to do that?
You can add a XamMultiColumnComboEditor to the cells of the grid by creating a new style targeting a CellValuePresenter and adding the combo editor to its template. You can then hook up the SelectedItem to the Id property and use a converter to set the Id to the proper value based on what item was selected.
As for populating the combo editor I wasn't sure how you planned on doing it from your description so I just gave it some random data. I've attached the sample.
Let me know if you have any questions on this.
Let me know if you still need any assistance on this matter.
So far it's quite ok but the MultiColumnCombo is displayed as a ComboBox on every line and not just on the active row resp. active cell. Is there an easy way to achieve that the Combo is not displayed (just the lookup value itself) except I'm in the edit mode of the cell? More like a FieldSettings.EditorStyle. Sorry for bugging but I'm a beginner in this area.
If you want that kind of behavior check out this blog post by Andrew Smith. http://www.infragistics.com/community/blogs/andrew_smith/archive/2009/03/27/hosting-wpf-controls-in-a-xamdatagrid-cell.aspx
It has a sample that shows how you can have two sets of DataTemplates for each cell, one for edit mode and one for non-edit mode. This way you can specify to use the combo control as the edit mode control while specifying a TextBlock for the non-edit mode version.
Let me know if you have any further questions on this matter.