我正在使用Windows Phone Control工具包中的ContextMenu.想知道如何知道列表中的哪个列表项被按下?似乎我可以知道选择了哪个上下文菜单,但我无法知道操作哪个列表项.请帮忙.谢谢!
<DataTemplate x:Key="ListItemTemplate">
<StackPanel Grid.Column="1" VerticalAlignment="Top">
<TextBlock Tag="{Binding Index}" Text="{Binding SName}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" />
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu>
<toolkit:MenuItem Header="Add to playlist" Click="Move_Click"/>
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
</StackPanel>
private void Move_Click(object sender, RoutedEventArgs e)
{
String name = (string)((MenuItem)sender).Header;
// how to know which index of the item is targeted on
}
Run Code Online (Sandbox Code Playgroud) silverlight xaml contextmenu silverlight-toolkit windows-phone-8