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
2085
Cascading ComboBoxColumns in XamGrid
posted

Hello,

I have a XamGrid with 2 ComboBoxColumns.  I set their ItemSource in my c# codebehind.  I need to allow the ComboBoxes in the columns to cascade, meaning when I select a value in ComboBox1 then ComboBox2 is populated based on what was selected in ComboBox1.  This would be similar to a State and City comboboxcolumn scenario.

Select State in ComboBox1 which fires an event to populate ComboBox2 with only the cities that are contained in that state.

How can I do this?

Parents
  • 34690
    Offline posted

    Hello Gary,

    In order to achieve your requirement in this case, I would recommend having an underlying collection property on your underlying data item that will represent your dependent combo’s ItemsSource. Doing this, you can assign that ItemsSource in your ViewModel in the setter of the dependent property.

    In your XAML, you can define an EditorStyle which will take a Style targeting ComboBox in the case of the ComboBoxColumn. The data context of the ComboBox will be your underlying data item, and you can then bind its ItemsSource to the underlying collection property mentioned above.

    I am attaching a sample project to demonstrate the above. I hope it helps you.

    It is worth noting that we generally recommend that you use the XamDataGrid control instead of the XamGrid control at this point. The XamGrid control is being planned for retirement over the next few years and will not be receiving any new features. We will continue to provide support and critical bug fixes to the XamGrid during this time, though.

    Please let me know if you have any other questions or concerns on this matter.

    XamGridCascadingCombo.zip

Reply Children