title: How can I reference the ListView DataContext from within the ListView.ItemTemplate in XAML?
body: <p>I have a ListView whose DataContext is set to my ViewModel. The ListView.ItemsSource is set to a Collection Property of the ViewModel. There is a Property called MyIndex say on this ViewModel. The value of MyIndex changes during the execution of my project.</p>
  
  <p>I need a way to access in XAML 'MyIndex' from within the ItemTemplate of the ListView so that I can change aspects of each ListViewItem based on the value of MyIndex. </p>
  
  <p>I can't use TemplatedParent and then the .Parent property of the ListViewItem in the binding as .Parent isn't the ListView. </p>
  
  <p>Here is some pseudo XAML to illustrate better what I mean.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>            &lt;ListView ItemsSource="ItemsCollection"&gt;
                  &lt;ListView.ItemTemplate&gt;
                      &lt;ItemContainerTemplate&gt;
                          &lt;Grid Background="{Binding &lt;some xaml to reference MyIndex Property of ListView.DataContext to use in Converter&gt;}"&gt;
  
                          &lt;/Grid&gt;
                      &lt;/ItemContainerTemplate&gt;
                  &lt;/ListView.ItemTemplate&gt;
              &lt;/ListView&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I'm not experienced with WPF so I hope this makes sense.</p>
  
  <p>Many thanks in advance for any help.</p>