To make the WPF version work, place an Image control on the form If you now run the program - with the Kinect plugged in of course - you will see a video displayed in the Image control.
The Windows Forms and WPF programs described above are the very simplest examples possible. They lack code to handle the proper selection of the Kinect device to use and they lack any error handling - particularly what to do if a Kinect isn't ready or available. We can deal with such details later. However there are two things we really need to deal with at this early stage.
The first is switching off the data streams when the program has finished using them.
The second problem is that, if you stop the application by closing its window, you will see an error reporting that the ColorImageFrame doesn't exist. The reason is that the OpenColorImageFrame method returns null if the image data has been abandoned for one reason or another. The solution is to add a test for a null ColorImageFrame:
Another problem with the example is that the byte array, bitmaps and other objects are created each time the event handler runs. This is OK for a demonstration but for a real application you need to write code that creates everything outside of the render loop i.e. the event handler, to minimize the work it has to do.
From here you can start to investigate the additional features of the video sensor, add a video capture facility for example.
You can control the video camera's angle by setting the tilt of the entire Kinect. Add two buttons, label one Up and the other Down and enter:
Also take care when using the motor driven elevation control - you can burn the motor out if you make it move to often. The code for the buttons given above doesn't check to make sure that you haven't attempted to move it beyond its allowed range - so you can crash the program.
Notice that in general no error handling is included in any of the code so that you can see how it works more easily and in practice you would need to add Try-Catch statements to make sure that the application didn't crash.
You can download the code for both the Windows Forms version and the WPF version in a single ZIP file from the CodeBin (note you have to register first).