Click here to Skip to main content
15,672,399 members
Articles / Desktop Programming / WPF
Posted 24 Dec 2013

Tagged as


16 bookmarked

Kinect status and setup the Kinect for interaction

Rate me:
Please Sign up or sign in to vote.
4.87/5 (10 votes)
24 Dec 2013CPOL2 min read
Kinect for windows status and setup the Kinect for interaction


The article will give you a getting started with kinect for windows sensor SDK 1.8 and how the kinect for interaction works. I am going to use the kinect sdk 1.8 and a WPF project using visual studio. 


  • Visual studio 2012
  • .NET 4.5
  • Kinect for windows sensor device.
  • Kinect for Windows SDK (
  • Kinect for Windows Developer Toolkit ( 

Kinect for window sensor status

Create a WPF Application project WPFKinect18 using visual studio 2012.

Image 1

Add the following references:From the C:\Program Files\Microsoft SDKs\Kinect\v1.8\Assemblies\ folder, add Microsoft.Kinect.dll.

Image 2

From the C:\Program Files\Microsoft SDKs\Kinect\Developer Toolkit v1.8.0\Assemblies\ folder, add Kinect.Toolkit.dll, Kinect.Toolkit.Controls.dll and Kinect.Toolkit.Interaction.dll

Image 3

Add the KinectSensorChooserUI to the MainWindow to get the Status of the Kinect sensor. Plugged, unplugged, powered.

And a label control to display the Kinect status change. 

Image 4

Image 5

Kinect not connected

Image 6

Kinect is initializing (you can see the status by hovering on it)

Image 7

Kinect Connected

Image 8

Setup the Kinect for interaction

Copy these “KinectInteraction180_32.dll, KinectInteraction180_64.dll” dll’s on the output directory of your project. As shown below (you can find these dll’s in the source code of this article.)

Image 9

Now change the “SensorChooserOnKinectChanged” event by the following code.

Image 10

On the mainwindows.xaml

<k:kinectuserviewer k:kinectregion.kinectregion="{Binding ElementName=kinectRegion}" height="150" primaryusercolor="Violet" usercoloringmode="HighlightPrimary" horizontalalignment="Right" verticalalignment="Bottom">

Image 11

You can see the user depth image on the right bottom of the screen. User is detected in-front of Kinect but not active. The user is looking gray colored

Image 12

Now the user is active and moving hand and its depth image becomes colored. And you can also see the user’s hand, both hands are track able. You can switch hand cursor control from left hand to right hand easily.

Adding the Kinect tile button inside the Kinect region

<k:kinecttilebutton click="ClickMe_Click" label="Click Me" x:name="ClickMe" />

In the MainWindow.cs page.

private void ClickMe_Click(object sender, RoutedEventArgs e)
            KinectStatus.Content = "Clicked me";

Hover hand on the button on the button

Image 13

Taking your hand towards Kinect sensor, like pushing a button. Partial pushed button

Image 14

Pressed button looks like this.

Image 15

Take you hand back to fire up the click event of this button.

Image 16

For scrolling area on the Kinect: grip your figures and scroll from left to right and right to left.

Image 17

Using the code  


<Window x:Class="WPFKinectSDK18.MainWindow"
        Title="MainWindow" Height="450" Width="625" Loaded="Window_Loaded" WindowState="Maximized">
        <k:KinectSensorChooserUI HorizontalAlignment="Center" VerticalAlignment="Top" Name="sensorChooserUi" />
        <Label x:Name="KinectStatus" Content="Kinect status change" 
               HorizontalAlignment="Left" VerticalAlignment="Bottom" FontSize="15"></Label>
        <k:KinectRegion x:Name="kinectRegion">
                <k:KinectUserViewer VerticalAlignment="Bottom" HorizontalAlignment="Right" 
                UserColoringMode="HighlightPrimary" PrimaryUserColor="Violet" Height="150"
                k:KinectRegion.KinectRegion="{Binding ElementName=kinectRegion}" />
                <k:KinectTileButton x:Name="ClickMe" Label="Click Me" Click="ClickMe_Click" VerticalAlignment="Top" HorizontalAlignment="Left"></k:KinectTileButton>
                <k:KinectScrollViewer VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Auto" VerticalAlignment="Center">
                    <StackPanel Orientation="Horizontal" x:Name="StackPanelWithButton" />
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Kinect;
using Microsoft.Kinect.Toolkit;
using Microsoft.Kinect.Toolkit.Controls;

namespace WPFKinectSDK18
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
        private KinectSensorChooser sensorChooser;
        public MainWindow()
        private void Window_Loaded(object sender, RoutedEventArgs e)
            this.sensorChooser = new KinectSensorChooser();
            this.sensorChooser.KinectChanged += SensorChooserOnKinectChanged;
            this.sensorChooserUi.KinectSensorChooser = this.sensorChooser;
        private void SensorChooserOnKinectChanged(object sender, KinectChangedEventArgs args)
            bool error = false;
            if (args.OldSensor != null)
                    args.OldSensor.DepthStream.Range = DepthRange.Default;
                    args.OldSensor.SkeletonStream.EnableTrackingInNearRange = false;
                catch (InvalidOperationException inEX) { error = true; }

            if (args.NewSensor != null)
                switch (Convert.ToString(args.NewSensor.Status))
                    case "Undefined": KinectStatus.Content = "Undefined"; break;
                    case "Disconnected": KinectStatus.Content = "Disconnected"; break;
                    case "Connected": KinectStatus.Content = "Connected"; break;
                    case "Initializing": KinectStatus.Content = "Initializing"; break;
                    case "Error": KinectStatus.Content = "Error"; break;
                    case "NotPowered": KinectStatus.Content = "NotPowered"; break;
                    case "NotReady": KinectStatus.Content = "NotReady"; break;
                    case "DeviceNotGenuine": KinectStatus.Content = "DeviceNotGenuine"; break;
                    case "DeviceNotSupported": KinectStatus.Content = "DeviceNotSupported"; break;
                    case "InsufficientBandwidth": KinectStatus.Content = "InsufficientBandwidth"; break;
                    default: KinectStatus.Content = "Undefined"; break;
                        args.NewSensor.DepthStream.Range = DepthRange.Near;
                        args.NewSensor.SkeletonStream.EnableTrackingInNearRange = true;
                        args.NewSensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
                    catch (InvalidOperationException inEX)
                        args.NewSensor.DepthStream.Range = DepthRange.Default;
                        args.NewSensor.SkeletonStream.EnableTrackingInNearRange = false;
                        error = true;
                catch (InvalidOperationException inEX) { error = true; }
            if (!error) { kinectRegion.KinectSensor = args.NewSensor; }

        private void ClickMe_Click(object sender, RoutedEventArgs e)
            KinectStatus.Content = "Clicked me";

        private void GetTileButtonsForStackPanel()
            for (int i = 1; i <= 35; i++)
                KinectTileButton ObjTileButton = new KinectTileButton();                
                ObjTileButton.Height = 250;
                ObjTileButton.Label = i;
                ObjTileButton.Click += (o, Args) => KinectStatus.Content = "You clicked on tile button : " + i;


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Technical Lead Ignatiuz Software Pvt. Ltd.
India India
Working in the projects by using technologies (.Net, C#, MSSQL, Web, Desktop, Kinect based Natural user inter-phase development, dynamic CRM.)

Comments and Discussions

GeneralDownload link not found Pin
DineshChaudhary4-Aug-20 21:20
DineshChaudhary4-Aug-20 21:20 
GeneralTrying to see if it works on xbox360 kinect with PC adapter Pin
Victor Ng15-Feb-15 22:11
Victor Ng15-Feb-15 22:11 
GeneralRe: Trying to see if it works on xbox360 kinect with PC adapter Pin
Pankaj Deharia25-Sep-15 1:53
professionalPankaj Deharia25-Sep-15 1:53 
QuestionThanks for your tut. Pin
Member 105060958-Apr-14 23:23
Member 105060958-Apr-14 23:23 
AnswerRe: Thanks for your tut. Pin
Pankaj Deharia8-Apr-14 23:58
professionalPankaj Deharia8-Apr-14 23:58 
QuestionWhere to buy Kinect for Windows in India Pin
ramatbellcity10-Mar-14 20:42
ramatbellcity10-Mar-14 20:42 
AnswerRe: Where to buy Kinect for Windows in India Pin
Pankaj Deharia Ignatiuz28-Mar-14 3:56
professionalPankaj Deharia Ignatiuz28-Mar-14 3:56 
QuestionProblem making it run Pin
N. Henrik Lauridsen6-Mar-14 1:40
N. Henrik Lauridsen6-Mar-14 1:40 
Nice article. I am though having a problem with your code. The user depth image (purple) doesn’t show and I can’t make it run the “move hand” action.
Please help to make it run. Thank you in advance.

Henrik Lauridsen
AnswerRe: Problem making it run Pin
Pankaj Deharia Ignatiuz28-Mar-14 3:43
professionalPankaj Deharia Ignatiuz28-Mar-14 3:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.