【问题标题】:detect which item is selected by the hand pointer (not mouse) in listbox wpf检测列表框wpf中的手形指针(不是鼠标)选择了哪个项目
【发布时间】:2017-09-10 12:05:17
【问题描述】:

是否有任何类似的方法来检测 listBox wpf 中的哪个项目已被 kinect v2 手形指针选择? 我尝试在列表框上使用选定触发器,但总是得到错误提示:'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());
    }



}

【问题讨论】:

    标签: c# wpf kinect-v2


    【解决方案1】:

    嗯? ListBox 有一个 SelectionChanged 事件和一个 SelectedItem 属性。 Selected 是 ListBoxItem 上的一个事件。在 ListBox 本身上捕获 SelectionChanged 事件。

    【讨论】:

    • 感谢您的回答,我使用 selectionchanged 但在第一次选择后使用手形指针时,它会像这样冻结:ibb.co/iBDo8a
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-12
    • 2012-10-29
    • 1970-01-01
    相关资源
    最近更新 更多