title: Dynamically changing ItemsSource of a WPF ComboBox
body: <p>I have a WPF application that contains two comboboxes (we'll call them cbox1 and cbox2).  cbox1 has its ItemsSource bound to an enum via XAML like this:</p>
  
  <pre><code>&lt;Window.Resources&gt;
      &lt;local:EnumDescriptionConverter x:Key="enumDescriptionConverter"/&gt;
      &lt;ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}" x:Key="cbox1DataProvider"&gt;
          &lt;ObjectDataProvider.MethodParameters&gt;
              &lt;x:Type TypeName="local:MyModel+ModeOfTransportationEnum"/&gt;
          &lt;/ObjectDataProvider.MethodParameters&gt;
      &lt;/ObjectDataProvider&gt;
  &lt;/Window.Resources&gt;
  
  &lt;ComboBox x:Name="cbox1" ItemsSource="{Binding Source={StaticResource cbox1DataProvider}}" SelectionChanged="cbox1_SelectionChanged"&gt;
      &lt;ComboBox.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;TextBlock Text="{Binding Converter={StaticResource enumDescriptionConverter}}"/&gt;
          &lt;/DataTemplate&gt;
      &lt;/ComboBox.ItemTemplate&gt;
  &lt;/ComboBox&gt;
  </code></pre>
  
  <p>The enum that cbox1's ItemsSource is bound to looks like this:</p>
  
  <pre><code>public enum ModeOfTransportationEnum
  {
      [Description("BMW X5")]
      BmwX5,
      [Description("Toyota Camry")]
      ToyotaCamry,
      [Description("Ford Focus")]
      FordFocus
  }
  </code></pre>
  
  <p>When my user selects an item in cbox1, I want to dynamically define the ItemsSource for cbox2.  For example, if my user selects "Toyota Camry" from cbox1, I want cbox2 to display the values "Red" and "Black".  If the user chooses "Ford Focus" from cbox1, I might want cbox2 to display "Silver", "Red" and "Blue".</p>
  
  <p>I've probably over-simplified the example but in a nutshell, I have three enums that I want to use for the .ItemsSource binding of cbox2.  I want to set the appropriate enum as the .ItemsSource for cbox2 based on what the user has selected in cbox1.  I was thinking that this could be accomplished with something similar to:</p>
  
  <pre><code>cbox2.SetBinding(ComboBox.ItemsSourceProperty, new Binding("AppropriateEnumGoesHere"));
  </code></pre>
  
  <p>Unfortunately, this doesn't seem to be working.  I don't get an error or anything but I also don't see my enum values being displayed in cbox2.  Also, as you can see in my XAML for cbox1 above, I'm using a converter to display the description attribute of each enum value.  The enums that I want to use as the .ItemsSource for cbox2 also have description attributes that I want to display instead of the raw enum values and I'm not sure how that should work from code, either.  Can anyone point me in the right direction?  Thanks!</p>