I have a long list selector
<phone:LongListSelector x:Name="BTDevices" SelectionChanged="BTDevices_SelectionChanged_1">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Path=Name}" FontSize="30" />
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
The function is defined as:
private void BTDevices_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
//here i want to get the index of the selected item
}
I tried the following line
int a = App.ViewModel.Items.IndexOf(sender as ItemViewModel);
But it always returns -1.