is there any similar way to detect which item in a listBox wpf had been selected by kinect v2 hand pointer? I tried to use selected trigger on listbox but always get and error that says: 'ListBox' does not contain a definition for 'Selected' and no extension method 'Selected' accepting a first argument of type '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());
}
}
Huh? ListBox has a SelectionChanged event and a SelectedItem property. Selected is an event on ListBoxItem. Trap the SelectionChanged event on the ListBox itself.