title: WPF ComboBox in DataGridTemplateColumn with alternate ItemsSource
body: <p>I am aware that this topic has come up a few times before, but I have tried the ways that I found here and none seem to work. I don't know if it's because I am using different binding sources, or if I'm just failing, or what...</p>
  
  <p>I have a DataGrid which is bound to an XML document read into memory. I have a List containing all of the distinct values that one column could be and want to use this as the ItemsSource for the ComboBox column.</p>
  
  <p>My XAML is as follows:</p>
  
  <pre><code>&lt;DataGrid AutoGenerateColumns="False" IsReadOnly="False"  Height="400" HorizontalAlignment="Left" Margin="125,15,0,0" x:Name="dg" VerticalAlignment="Top" Width="500"&gt;
      &lt;DataGrid.Columns&gt;
          &lt;DataGridTextColumn Header="Name" Width="40*" Binding="{Binding Path=Element[name].Value}" /&gt;
          &lt;DataGridTextColumn Header="Count" Width="10*" Binding="{Binding Path=Attribute[count].Value}" /&gt;
  
  &lt;!-- I want this to be a ComboBox in a DataGridTemplateColumn --&gt;
          &lt;DataGridTextColumn Header="Category" Width="25*" Binding="{Binding Path=Attribute[category].Value}" /&gt; 
  
          &lt;DataGridTextColumn Header="Image Path" Width="25*" Binding="{Binding Path=Element[image].Value}" /&gt;
      &lt;/DataGrid.Columns&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>And a sample XML node which si displayed would look like this:</p>
  
  <pre><code>&lt;entry count="1" category="someCategory"&gt;
      &lt;name&gt;Entry 1&lt;/name&gt;
      &lt;image&gt;c:\image.png&lt;/image&gt;
  &lt;/entry&gt;
  </code></pre>
  
  <p>Finally, the list which I want to use as the ItemsSource for the ComboBoxes:</p>
  
  <pre><code>var categories = from category in xmlDoc.Root.Elements("entry") select category .Attribute("category").Value;
  List&lt;string&gt; catList= categories .ToList&lt;string&gt;();
  </code></pre>
  
  <p>So when a user edits the category field I want them to have a dropdown containing the possible values contained in the list.</p>
  
  <hr />
  
  <p>EDIT: Finally got this working, I did as stated in the accepted answer, set the ItemsSource of the ComboBox to  </p>
  
  <pre><code>ItemsSource="{DynamicResource categoryList}"
  </code></pre>
  
  <p>and then simply did this in the code after creating the list item I wanted to use to populate the ComboBoxes:</p>
  
  <pre><code>Resources["categoryList"] = catList;
  </code></pre>