有没有类似的方法来检测 kinect v2 手形指针选择了 listBox wpf 中的哪个项目?我试图在列表框上使用选定的触发器,但总是得到错误提示:'ListBox' 不包含'Selected' 的定义,并且没有扩展方法'Selected' 接受'ListBox' 类型的第一个参数
<ListBox x:Name="listBox" VerticalAlignment="Bottom" ItemTemplate="{DynamicResource ItemTemplate11}" ItemsSource="{Binding Collection}" Selected="listBox_Selected">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
public partial class MainWindow
{
/// <summary>
/// Initializes a new instance of the <see cref="MainWindow"/> class.
/// </summary>
public MainWindow()
{
this.InitializeComponent();
KinectRegion.SetKinectRegion(this, kinectRegion);
App app = ((App)Application.Current);
app.KinectRegion = kinectRegion;
// Use the default sensor
this.kinectRegion.KinectSensor = KinectSensor.GetDefault();
}
private void listBox_Selected(object sender, RoutedEventArgs e)
{
MessageBox.Show(listBox.SelectedIndex.ToString());
}
}