Coding4Fun Kinect Projects

SilverLight 5 and Kinect, via the magic of P-Invoke


Kinect and the Kinect for Windows SDK and SilverLight 5? Impossible, you say? Not so my friends, not so. Not only is it possible, but here's someone that's done it AND sharing their code too!

Silverlight 5 P-Invoke: Using Kinect SDK from Silverlight

...The Silverlight 5 RC contains the previously announced P-Invoke feature which enables you to call Win32 style APIs from a trusted Silverlight application.

There are some attempts to use Kinect from Silverlight (here) but this was before MS released the official SDK. we will use Silverlight 5 P-Invoke feature to call the Kinect SDK APIs.

P-Invoke in Silverlight works just like P-Invoke on the desktop. you use the DllImport attribute to import the APIs and you declare in your code the dependent types (Enums, structs, etc.)


I tried to keep the classes and methods in library identical to the ones in the official SDK. I implemented only a couple of the available APIs (with the help of the Coding4Fun Kinect Toolkit and Reflector).


Project Information URL:

Project Source URL: (and select and download "Silverlight 5 Library for Kinect")





private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
   Runtime runtime = (App.Current as App).KinectRuntime;
   runtime.VideoStream.OpenStream(ImageType.Color, ImageResolution.Resolution640x480);
  runtime.DepthStream.OpenStream(ImageType.Depth, ImageResolution.Resolution320x240);
runtime.VideoFrameReady += new EventHandler<ImageFrameReadyEventArgs>(runtime_VideoFrameReady);
   runtime.DepthFrameReady += new EventHandler<ImageFrameReadyEventArgs>(runtime_DepthFrameReady);
void runtime_VideoFrameReady(object sender, ImageFrameReadyEventArgs e)
    Dispatcher.BeginInvoke(() => {
        image1.Source = e.ImageFrame.ToBitmapSource();
void runtime_DepthFrameReady(object sender, ImageFrameReadyEventArgs e)
    Dispatcher.BeginInvoke(() =>
        image2.Source = e.ImageFrame.ToBitmapSource();


Contact Information:

The Discussion

  • mle_ii

    Will this method or just using the managed dlls from the SDK work in a Metro (Windows 8) application?  I know it wouldn't get approved since it's not part of the WinRT, but I'd like to see if I can write a full screen Metro style app with Kinect.  Though I'm not sure that the drivers and SDK even work on Win 8.  I really hope we can get a WinRT version of the Kinect SDK as this would be very cook for when I have my tablet connected to my HD TV.


  • Gene

    Cool =) You can also use Kinect (wii motes and lot more) starting from Silverlight 2 and up using MIRIA SDK ( .
    See video here :


Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.