Hello, Thanks in advance for any help. I've got two combo boxes which I'd like to be dependent on each others input. For example, when I update one, it filters the available values for the next. Thought I had everything working until after I switched between the two a few times, both just because blank.
I've got two combo boxes with countries, FromCountry and ToCountry. These are bound to an ObservableCollection called Countries. I thought it might make sense to use the DroDownOpened event to limit the values available in the dropping down combobox.
Any suggestions or help would greatly be appreciated.
Method that gets called when you click the drop down on the To Country
private void ToCountry_DropDownOpened(object sender, EventArgs e)
{
int FromId = (Countries.Country)FromCountry.selectedItem).ID;
int ToId = (Countries.Country)ToCountry.selectedItem).ID;
this.ToCountry.ItemsSource = AppInfo.CountryList.Where(p=>p.ID!=FromId).OrderBy(c => c.Name);
}
Method that gets called when you click the drop down on the From Country
private void FromCountry_DropDownOpened(object sender, EventArgs e)
{
int FromId = (Countries.Country)FromCountry.selectedItem).ID;
int ToId = (Countries.Country)ToCountry.selectedItem).ID;
this.FromCountry.ItemsSource = AppInfo.CountryList.Where(p=>p.ID!=ToId).OrderBy(c => c.Name);
}