Index of ListViewItem Tapped in Tapped Event
<p>So, I am designing a Universal Windows app which uses a ListView with data bound to it which i create programatically. The XAML for my page:</p>

<pre><code>&lt;ListView x:Name="lvEpisodeListSource" Margin="10,170,10,10" ItemsSource="{Binding Source={StaticResource EpisodeListSource}}"&gt;
        &lt;ListView.ItemTemplate&gt;
            &lt;DataTemplate x:DataType="local:Episode"&gt;
                &lt;ListViewItem Background="CadetBlue" IsDoubleTapEnabled="False" IsHoldingEnabled="False" Tapped="ListViewItem_Tapped" IsRightTapEnabled="False" HorizontalAlignment="Stretch"&gt;
                    &lt;TextBlock Name="AlbumBlock" Foreground="Black" FontWeight="Normal" FontSize="15" Margin="5,0,0,0"
                                    Text="{x:Bind Name}" HorizontalAlignment="Left" VerticalAlignment="Center"/&gt;
                &lt;/ListViewItem&gt;
            &lt;/DataTemplate&gt;
        &lt;/ListView.ItemTemplate&gt;
        &lt;ListView.ItemContainerStyle&gt;
            &lt;Style TargetType="ListViewItem"&gt;
                &lt;Setter Property="HorizontalContentAlignment" Value="Stretch" /&gt;
            &lt;/Style&gt;
        &lt;/ListView.ItemContainerStyle&gt;
    &lt;/ListView&gt;
</code></pre>

<p>The data binds correctly and that all works fine. I am trying to then save the most recently clicked ListViewItem to LocalApplicationData. Currently, I am trying to do this by setting the Local App Data in the tapped event for the Items.</p>

<pre><code>private void ListViewItem_Tapped(object sender, TappedRoutedEventArgs e)
    {
        myData data = ((ListViewItem)sender).DataContext as myData;
        var clickedNumber = lvDataListSource.Items.IndexOf(((ListViewItem)sender));
    }
</code></pre>

<p>This is currently not working and the <code>clickedNumber</code> always returns -1 no matter which I click. Is there a way to get the index of the item which called the tapped event or is there a better way to do want I want to accomplish?</p>

<p>Thanks!</p>