检测列表框wpf中的手形指针(不是鼠标)选择了哪个项目
detect which item is selected by the hand pointer (not mouse) in listbox wpf
是否有任何类似的方法来检测 listBox wpf 中的哪个项目已被 kinect v2 指针选中?
我试图在列表框上使用选定的触发器,但总是得到错误提示:'ListBox' 不包含 'Selected' 的定义并且没有扩展方法 'Selected' 接受类型为 [=13 的第一个参数=]
<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());
}
}
嗯? ListBox 有一个 SelectionChanged 事件和一个 SelectedItem 属性。 Selected 是 ListBoxItem 上的一个事件。在 ListBox 本身上捕获 SelectionChanged 事件。
是否有任何类似的方法来检测 listBox wpf 中的哪个项目已被 kinect v2 指针选中? 我试图在列表框上使用选定的触发器,但总是得到错误提示:'ListBox' 不包含 'Selected' 的定义并且没有扩展方法 'Selected' 接受类型为 [=13 的第一个参数=]
<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());
}
}
嗯? ListBox 有一个 SelectionChanged 事件和一个 SelectedItem 属性。 Selected 是 ListBoxItem 上的一个事件。在 ListBox 本身上捕获 SelectionChanged 事件。