title: Getting a WPF control to trigger and set another control's itemssource
body: <p>I'm working on a WPF application where I want to present a ComboBox with two choices. Depending on the choice in the first ComboBox, a second ComboBox's ItemsSource should change to display items of the type selected in the first ComboBox.</p>
  
  <p>However, I'm running into some circular problems with my approach. I'm new to WPF and MVVM, so perhaps I'm missing something obvious. None of the (many) examples I've found on the internet seem applicable to my situation.</p>
  
  <p>My XAML code:</p>
  
  <pre><code>&lt;ComboBox x:Name="cmbTargetType" SelectionChanged="cmbTargetType_SelectionChanged"&gt;
   &lt;Style TargetType="ComboBox"&gt;
    &lt;Style.Triggers&gt;
     &lt;Trigger Property="Text" Value="Materials"&gt;
      &lt;Setter TargetName="cmbTarget" Property="ItemsSource" Value="{Binding DataContext.MaterialListViewModel.MaterialViewModels.AllMaterials, RelativeSource={RelativeSource AncestorType=Window}}"&gt;&lt;/Setter&gt;
     &lt;/Trigger&gt;
     &lt;Trigger Property="Text" Value="ProductParts"&gt;
      &lt;Setter TargetName="cmbTarget" Property="ItemsSource" Value="{Binding DataContext.ProductViewModel.ProductPartViewModels.AllProductParts, RelativeSource={RelativeSource AncestorType=Window}}"&gt;&lt;/Setter&gt;
     &lt;/Trigger&gt;
    &lt;/Style.Triggers&gt;
   &lt;/Style&gt;
   &lt;ComboBoxItem Content="Material"/&gt;
   &lt;ComboBoxItem Content="ProductPart"/&gt;
  &lt;/ComboBox&gt;
  </code></pre>
  
  <p>This code gives me the error "TargetName property cannot be set on a Style Setter". Which I assume is because there's no DataContext available inside a style. However, when I remove the Style elements from the code, I end up with even more errors. It doesn't seem to recognize the properties 'Text' and 'ItemsSource', giving the error "Cannot find the static member 'TextProperty' on the type 'ContentPresenter'." Looking for answers to this error on the internet, the only answer I'm finding is putting the Triggers inside a style...</p>
  
  <p>What am I doing wrong here?</p>