title: mvvm ComboBox selection in Listview
body: <p>I am trying to display a collection of objects in a wpf-Listview and provide a combobox for selection of values from an other collection.</p>
  
  <p>Some code to illustrate my problem:</p>
  
  <pre><code>XAML: (Window gets its DataContext set in app.xaml.cs)
  
  &lt;ListView ItemsSource="{Binding Path=Books}" SelectedItem="{Binding Path=CurrentBook}"&gt;
      &lt;ListView.View&gt;
          &lt;GridView&gt;
              &lt;GridViewColumn Header="author" DisplayMemberBinding="{Binding author}" /&gt;
              &lt;GridViewColumn Header="title" DisplayMemberBinding="{Binding title}" /&gt;
              &lt;GridViewColumn Header="genre"&gt;
                  &lt;GridViewColumn.CellTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;ComboBox ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Genres}" IsSynchronizedWithCurrentItem="true" DisplayMemberPath="genreName" SelectedItem="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.CurrentBook_Genre}"&gt;
                          &lt;ComboBox.ItemTemplate&gt;
                              &lt;StackPanel Orientation="Horizontal"&gt;
                                 &lt;TextBlock Text="{Binding genreName}" /&gt;
                                 &lt;TextBlock Text="{Binding genreDescription}" /&gt;
                              &lt;/StackPanel&gt;
                       &lt;/DataTemplate&gt;
                  &lt;/GridViewColumn.CellTemplate&gt;
             &lt;/GridViewColumn&gt;
          &lt;/GridView&gt;
      &lt;/ListView.View&gt;
  &lt;/ListView&gt;
  </code></pre>
  
  <p>For now is "CurrentBook_Genre" a Property of the MainWindowViewModel, the according value of the Item shown in the ListView is set by its setter.</p>
  
  <p>Like that the same ComboBox is shown in every "row" of the ListView.
  I guess I need some kind of "EditValueTemplate" and "ShowValueTemplate" and a Selector of some kind, it would be fine, if the ComboBox gets shown only in the row which is in edit-mode - i guess this is a common thing for most DataDriven apps, so maybe there is a way more easy iam not aware of.</p>
  
  <p>The only good explanation for this was
  <a href="http://tech.pro/tutorial/857/wpf-tutorial-using-the-listview-part-3-in-place-edit" rel="nofollow">http://tech.pro/tutorial/857/wpf-tutorial-using-the-listview-part-3-in-place-edit</a>
  But they are working with dependency-properties, opposed to the ViewModel-wrapped models iam using.</p>