WPF Combobox linking issue
I have 2 comboboxes and based on selection in 1st one, I want to populate 2nd one. How can I do this with two classes Country and City?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Shweta LodhaPosted Mar 30, 2014, 11:52 PM
First create Country class that would contain country related information and all available city values in a collection. Somewhere in your code, instantiate a collection of the country and the corresponding cities.
In XAML, bind the ItemSource property of the combobox to that property. For 2nd combobox, bind it's ItemSource property to the list of cities from the SelectedItem of the first combobox.
Hope it will resolve your linking issue.
Shweta LodhaPosted Mar 30, 2014, 11:57 PM
SukaskhaPosted Mar 30, 2014, 11:57 PM
I'll give a try to this approach. Thanks for your suggestion.