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?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Shweta LodhaRank #31 · 39.8K reputationPosted Mar 30, 2014, 7:52 PM EDT
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.
Sukaskha131 reputationPosted Mar 30, 2014, 7:57 PM EDT
I'll give a try to this approach. Thanks for your suggestion.
Shweta LodhaRank #31 · 39.8K reputationPosted Mar 30, 2014, 7:57 PM EDT