我有一个很长的列表选择器
<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>
函数定义为:
private void BTDevices_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
//here i want to get the index of the selected item
}
我尝试了以下行
int a = App.ViewModel.Items.IndexOf(sender as ItemViewModel);
但它总是返回-1。