Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
310
MultiColumnComboBox in XamDataGrid
posted

Hi there

I have data items with the following structure

  • Id
  • IdRelated-Text1
  • IdRelated-Text2
  • other Properties

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?

Thanks
Roman

Parents
  • 34510
    Verified Answer
    Offline posted

    Hi Roman,

    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.

    xamDataGrid-MultiColumnComboInCell.zip
Reply Children