Obtener el índice del elemento seleccionado en longlistselector
Tengo un selector de lista larga
<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>
La función se define como:
private void BTDevices_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
//here i want to get the index of the selected item
}
Probé la siguiente línea
int a = App.ViewModel.Items.IndexOf(sender as ItemViewModel);
Pero siempre devuelve -1.