title: Silverlight Dependent or Filtering Combo Boxes
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>Any suggestions or help would greatly be appreciated.</p>
  
  <p>Method that gets called when you click the drop down on the To Country</p>
  
  <pre><code>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=&gt;p.ID!=FromId).OrderBy(c =&gt; c.Name);
  }
  </code></pre>
  
  <p>Method that gets called when you click the drop down on the From Country</p>
  
  <pre><code>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=&gt;p.ID!=ToId).OrderBy(c =&gt; c.Name);
  }
  </code></pre>