<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://dotneteers.net/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">VBandi&amp;#39;s blog</title><subtitle type="html">VBandi&amp;#39;s musings on WPF, SIlverlight and User Experience</subtitle><id>http://dotneteers.net/blogs/vbandi/atom.aspx</id><link rel="alternate" type="text/html" href="http://dotneteers.net/blogs/vbandi/default.aspx" /><link rel="self" type="application/atom+xml" href="http://dotneteers.net/blogs/vbandi/atom.aspx" /><generator uri="http://communityserver.org" version="4.0.30417.1769">Community Server</generator><updated>2012-03-23T16:17:00Z</updated><entry><title>Kinect Interactions with(out) WPF – Part III: Demystifying the Interaction Stream</title><link rel="alternate" type="text/html" href="/blogs/vbandi/archive/2013/05/03/kinect-interactions-with-wpf-part-iii-demystifying-the-interaction-stream.aspx" /><id>/blogs/vbandi/archive/2013/05/03/kinect-interactions-with-wpf-part-iii-demystifying-the-interaction-stream.aspx</id><published>2013-05-03T19:43:20Z</published><updated>2013-05-03T19:43:20Z</updated><content type="html">&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_2D9080F7.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;margin-left:0px;border-left:0px;display:inline;margin-right:0px;" border="0" alt="image" align="right" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_6AD135BE.png" width="244" height="176" /&gt;&lt;/a&gt; &lt;em&gt;In this part of my &lt;a href="http://dotneteers.net/blogs/vbandi/archive/tags/Kinect+Interactions/default.aspx" target="_blank"&gt;Kinect Interaction blog post series&lt;/a&gt;, we go deep into the rabbit hole, and examine the foundation of Kinect Interactions – the &lt;strong&gt;InteractionStream&lt;/strong&gt;, upon which the entire library is built. This is a risky ride – with no official documentation, we can only count on our trusty reflector, the source code of the Kinect Interaction SDK and careful exploration. &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;You only need to access the treasures of &lt;strong&gt;InteractionStream&lt;/strong&gt;, if you want to go beyond what the &lt;strong&gt;&lt;a href="http://vbandi.dotneteers.net/blogs/vbandi/archive/2013/03/25/kinect-interactions-with-wpf-part-i-getting-started.aspx" target="_blank"&gt;KinectRegion and other controls&lt;/a&gt;&lt;/strong&gt; provide. For example, you want to create your own KinectRegion, you want to zoom a map by gripping it with two hands, or want to build your entirely new interaction model, using two hands along with the press and grip gestures.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;  &lt;h2&gt;Initializing the InteractionStream&lt;/h2&gt;  &lt;h2&gt;&lt;/h2&gt;  &lt;p&gt;Initializing the InteractionStream is much like initializing the DepthStream or the SkeletonStream. If you have a KinectSensor object, all you need are the next two lines of code:&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;_interactionStream = &lt;span class="kwrd"&gt;new&lt;/span&gt; InteractionStream(_sensor, &lt;span class="kwrd"&gt;new&lt;/span&gt; DummyInteractionClient());&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;_interactionStream.InteractionFrameReady += InteractionStreamOnInteractionFrameReady;&lt;/pre&gt;
&lt;/div&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;What is the DummyInteractionClient that we pass in the constructor? Turns out, that the InteractionStream needs an object that implements the &lt;strong&gt;IInteractionClient&lt;/strong&gt; interface to work. The interface defines a single method: &lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; IInteractionClient&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;  InteractionInfo GetInteractionInfoAtLocation(&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;      &lt;span class="kwrd"&gt;int&lt;/span&gt; skeletonTrackingId, &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;      InteractionHandType handType, &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;      &lt;span class="kwrd"&gt;double&lt;/span&gt; x, &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;      &lt;span class="kwrd"&gt;double&lt;/span&gt; y);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;X&lt;/strong&gt; and &lt;strong&gt;Y&lt;/strong&gt; are obviously coordinates, &lt;strong&gt;skeletonTrackingID&lt;/strong&gt; is the identifier of the user. The &lt;strong&gt;InteractionHandType &lt;/strong&gt;type is a simple enum with the values of “&lt;strong&gt;None&lt;/strong&gt;”, “&lt;strong&gt;Left&lt;/strong&gt;”, “&lt;strong&gt;Right&lt;/strong&gt;”, identifying the hand of the user. The InteractionInfo class has the following members:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;sealed&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; InteractionInfo&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;  &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; IsPressTarget { get; set; }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;  &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; PressTargetControlId { get; set; }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;  &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt; PressAttractionPointX { get; set; }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;  &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt; PressAttractionPointY { get; set; }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;  &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; IsGripTarget { get; set; }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;At this point, my Spider-sense tingles, and I think I have guessed the purpose of the IInteractionClient interface: it’s &lt;strong&gt;GetInteractionInfoAtLocation&lt;/strong&gt; method is called to determine that when the hand cursor of a certain user’s certain hand is at a certain position, is that position pressable and / or grippable. So, I created a dummy implementation of the IInteractionClient interface that keeps saying YES to all these questions.&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; DummyInteractionClient : IInteractionClient&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; InteractionInfo GetInteractionInfoAtLocation(&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;        &lt;span class="kwrd"&gt;int&lt;/span&gt; skeletonTrackingId, &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        InteractionHandType handType, &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;        &lt;span class="kwrd"&gt;double&lt;/span&gt; x, &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;        &lt;span class="kwrd"&gt;double&lt;/span&gt; y)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;        var result = &lt;span class="kwrd"&gt;new&lt;/span&gt; InteractionInfo();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;        result.IsGripTarget = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;        result.IsPressTarget = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;        result.PressAttractionPointX = 0.5;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;        result.PressAttractionPointY = 0.5;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;        result.PressTargetControlId = 1;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;        &lt;span class="kwrd"&gt;return&lt;/span&gt; result;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;It seems like we are on track. Just pass an initialized &lt;strong&gt;KinectSensor&lt;/strong&gt; object and this &lt;strong&gt;DummyInteractionClient&lt;/strong&gt; to the constructort of the &lt;strong&gt;InteractionStream&lt;/strong&gt;, and we should be all set, right? Well, not quite. The &lt;strong&gt;InteractionFrameReady&lt;/strong&gt; event does not fire.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h2&gt;Interaction Needs Skeleton and Depth&lt;/h2&gt;

&lt;p&gt;It turns out, that for the InteractionStream to work, it needs to process the data from both the depth and the skeleton streams. So, we need to initiate all three of the streams. This is what the entire OnLoaded method (which you have to wire up either in XAML or in the constructor of the page) looks like:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; KinectSensor _sensor;  &lt;span class="rem"&gt;//The Kinect Sensor the application will use&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; InteractionStream _interactionStream;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; Skeleton[] _skeletons; &lt;span class="rem"&gt;//the skeletons &lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; UserInfo[] _userInfos; &lt;span class="rem"&gt;//the information about the interactive users&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnLoaded(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs routedEventArgs)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (DesignerProperties.GetIsInDesignMode(&lt;span class="kwrd"&gt;this&lt;/span&gt;))&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;        &lt;span class="kwrd"&gt;return&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;    &lt;span class="rem"&gt;// this is just a test, so it only works with one Kinect, and quits if that is not available.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;    _sensor = KinectSensor.KinectSensors.FirstOrDefault();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (_sensor == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;        MessageBox.Show(&lt;span class="str"&gt;&amp;quot;No Kinect Sensor detected!&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;        Close();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;        &lt;span class="kwrd"&gt;return&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;    _skeletons = &lt;span class="kwrd"&gt;new&lt;/span&gt; Skeleton[_sensor.SkeletonStream.FrameSkeletonArrayLength];&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;    _userInfos = &lt;span class="kwrd"&gt;new&lt;/span&gt; UserInfo[InteractionFrame.UserInfoArrayLength];&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;    _sensor.DepthStream.Range = DepthRange.Near;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;    _sensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;    _sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;    _sensor.SkeletonStream.EnableTrackingInNearRange = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;    _sensor.SkeletonStream.Enable();&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;    _interactionStream = &lt;span class="kwrd"&gt;new&lt;/span&gt; InteractionStream(_sensor, &lt;span class="kwrd"&gt;new&lt;/span&gt; DummyInteractionClient());&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt;    _interactionStream.InteractionFrameReady += InteractionStreamOnInteractionFrameReady;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  34:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  35:  &lt;/span&gt;    _sensor.DepthFrameReady += SensorOnDepthFrameReady;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  36:  &lt;/span&gt;    _sensor.SkeletonFrameReady += SensorOnSkeletonFrameReady;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  37:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  38:  &lt;/span&gt;    _sensor.Start();&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  39:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;div class="csharpcode"&gt;&amp;#160;&lt;/div&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;It doesn’t seem so simple now, so let&amp;#39;s walk through each line of code and see what they do. The first five lines define local variables that hold a reference to the Kinect sensor the application will use, the InteractionStream itself, the skeletons identified by the SkeletonStream, and the hand position information about the users as determined by the InteractionStream.&lt;/p&gt;

&lt;p&gt;Line 9 makes sure that we don&amp;#39;t do anything when running in the designer. Lines 12 through 19 initialize the first available KinectSensor. Note, that for simplicity&amp;#39;s sake, we are not using the &lt;strong&gt;KinectSensorChooser&lt;/strong&gt; introduced in the &lt;a href="http://dotneteers.net/blogs/vbandi/archive/2013/03/25/kinect-interactions-with-wpf-part-i-getting-started.aspx" target="_blank"&gt;first part of the series&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After that, the &lt;strong&gt;_skeletons &lt;/strong&gt;array is initialized to the maximum amount of skeletons the &lt;strong&gt;SkeletonStream&lt;/strong&gt; can handle. Similarly, the _userInfos array (which will store the information we get from the &lt;strong&gt;InteractionStream&lt;/strong&gt;) is initialized to the maximum number of users the &lt;strong&gt;InteractionStream&lt;/strong&gt; can work with. Both of these are 6 at the moment, but it is safer to use this initialization method to be future-proof. The rest is fairly standard initialization for the Kinect SDK. Note that we are using than the near mode of the Kinect for Windows sensor, which may not be available if you are using the Kinect for Xbox sensor. In this case, you may want turn these off in lines 25 and 29.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The event handlers for the &lt;strong&gt;SkeletonFrameReady&lt;/strong&gt; and &lt;strong&gt;DepthFrameReady&lt;/strong&gt; events are fairly simple, but there’s a little bit of error handling that makes them longer. I emphasized the key parts below:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SensorOnSkeletonFrameReady(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, SkeletonFrameReadyEventArgs skeletonFrameReadyEventArgs)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (&lt;strong&gt;SkeletonFrame skeletonFrame = skeletonFrameReadyEventArgs.OpenSkeletonFrame())&lt;/strong&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (skeletonFrame == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;        &lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;            &lt;strong&gt;skeletonFrame.CopySkeletonDataTo(_skeletons);&lt;/strong&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;strong&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;            var accelerometerReading = _sensor.AccelerometerGetCurrentReading();&lt;/strong&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;strong&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;            _interactionStream.ProcessSkeleton(_skeletons, accelerometerReading, skeletonFrame.Timestamp);&lt;/strong&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;        &lt;span class="kwrd"&gt;catch&lt;/span&gt; (InvalidOperationException)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;            &lt;span class="rem"&gt;// SkeletonFrame functions may throw when the sensor gets&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;            &lt;span class="rem"&gt;// into a bad state.  Ignore the frame in that case.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Essentially, we acquire a &lt;strong&gt;SkeletonFrame&lt;/strong&gt;, and pass it to the &lt;strong&gt;ProcessSkeleton&lt;/strong&gt; method of the &lt;strong&gt;InteractionStream&lt;/strong&gt;, along with the accelerometer reading coming from the Kinect sensor and the timestamp. &lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;DepthFrameReady&lt;/strong&gt; event handler is pretty similar:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SensorOnDepthFrameReady(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, DepthImageFrameReadyEventArgs depthImageFrameReadyEventArgs)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (DepthImageFrame depthFrame = &lt;strong&gt;depthImageFrameReadyEventArgs.OpenDepthImageFrame())&lt;/strong&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (depthFrame == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;        &lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;           &lt;strong&gt; _interactionStream.ProcessDepth(depthFrame.GetRawPixelData(), depthFrame.Timestamp);&lt;/strong&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;        &lt;span class="kwrd"&gt;catch&lt;/span&gt; (InvalidOperationException)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;            &lt;span class="rem"&gt;// DepthFrame functions may throw when the sensor gets&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;            &lt;span class="rem"&gt;// into a bad state.  Ignore the frame in that case.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;We acquire a &lt;strong&gt;DepthFrame&lt;/strong&gt;, get its raw pixel data, and pass it over for processing to the &lt;strong&gt;InteractionStream&lt;/strong&gt;, along with a timestamp. And finally, the &lt;strong&gt;InteractionFrameReady&lt;/strong&gt; event gets called. Yay!&lt;/p&gt;

&lt;h2&gt;Dissecting InteractionFrameReadyEventArgs&lt;/h2&gt;

&lt;p&gt;So, now that we have finally made the &lt;strong&gt;InteractionStream&lt;/strong&gt; call the &lt;strong&gt;InteractionFrameReady&lt;/strong&gt; event, we can start analyzing what kind of data we can get to. The first step is to get our hand on an &lt;strong&gt;InteractionFrame&lt;/strong&gt;, and the interaction data it contains:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; (var iaf = args.OpenInteractionFrame()) &lt;span class="rem"&gt;//dispose as soon as possible&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (iaf == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;        &lt;span class="kwrd"&gt;return&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    iaf.CopyInteractionDataTo(_userInfos);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Remember – the _userInfos array is an array of UserInfo objects. A &lt;strong&gt;UserInfo&lt;/strong&gt; object contains all the interaction data related to that specific user. More specifically it has two public properties:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;int &lt;strong&gt;SkeletonTrackingId&lt;/strong&gt;, which is the id of the user corresponding to the user ID in the SkeletonStream. If the skeletonTrackingID property equals 0, its means that the UserInfo object does not contain a valid user.&lt;/li&gt;

  &lt;li&gt;ReadOnlyCollection&amp;lt;InteractionHandPointer&amp;gt; &lt;strong&gt;HandPointers&lt;/strong&gt;, which contains the hands of the specified user (this collection probably has no more than two items most of the time).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let&amp;#39;s dig deeper! The next class to examine is the &lt;strong&gt;InteractionHandPointer&lt;/strong&gt; class. This class represents one hand of the user. I have used a small WPF application along with the Kinect Studio to understand the properties, and displayed all properties of the &lt;strong&gt;InteractionHandPointer&lt;/strong&gt; class in a nifty little window. Here is the output from my Kinect, with me sitting in front of my computer: &lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_783748C4.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_5743D61D.png" width="629" height="484" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;On the right is the depth stream, and the super-cool 3D Viewer from Kinect Studio. I have both of my hands in the air, with the left hand closed, and the right one open. The keen eyed ones among you may realize that the two pictures seem to be not just from a different point of view, but also mirrored – it looks like my right hand is closed instead of my left. It is just how the display is.&lt;/p&gt;

&lt;p&gt;On the left side of the screenshot, you can see the output of my little program, showing the properties of the &lt;strong&gt;InteractionHandPointer&lt;/strong&gt; class (and a little more). I will discuss all of these in detail below. &lt;/p&gt;

&lt;h3&gt;&lt;/h3&gt;

&lt;h3&gt;InteractionHandType HandType&lt;/h3&gt;

&lt;p&gt;Indicates whether the hand that belongs to the InteractionHandPointer is the left hand (&lt;strong&gt;Left)&lt;/strong&gt;, right hand (&lt;strong&gt;Right&lt;/strong&gt;), or neither (&lt;strong&gt;None&lt;/strong&gt;). Which sounds a bit funny, but the enumeration still has this option.&lt;/p&gt;

&lt;h3&gt;bool IsActive&lt;/h3&gt;

&lt;p&gt;Indicates whether this hand is active. A hand is considered active if it is raised and is in front of the user.&lt;/p&gt;

&lt;h3&gt;InteractionHandEventType HandEventType&lt;/h3&gt;

&lt;p&gt;This is another enumeration, showing the grip event that has happened to the hand in &lt;strong&gt;this&lt;/strong&gt; frame. Which means that if you have performed a Grip gesture (closed your hand), the value of HandEventType will only be &lt;strong&gt;Grip&lt;/strong&gt; or &lt;strong&gt;GripRelease &lt;/strong&gt;for one frame! It would be very useful to have a boolean property for this event, since now we have to track the last event that is not &lt;strong&gt;None&lt;/strong&gt; to know whether a hand is open or closed. &lt;/p&gt;

&lt;h3&gt;InteractionHandEventType LastHandEventType&lt;/h3&gt;

&lt;p&gt;This is unfortunately not part of the &lt;strong&gt;InteractionHandPointer&lt;/strong&gt; class, but solves the abovementioned problem of storing the last grip event for each hand. You can find a sample code for tracking the last &lt;strong&gt;HandEventType&lt;/strong&gt; for every user and both hands in the attached solution. &lt;/p&gt;

&lt;p&gt;A bit of good news though: it seems like when the Kinect detects a user, it correctly sets the &lt;strong&gt;HandEventType&lt;/strong&gt; property in the first frame. This means that even if the user comes into the play area with his fist closed, you will know and you will be able to react accordingly. &lt;/p&gt;

&lt;h3&gt;bool IsPrimaryForUser&lt;/h3&gt;

&lt;p&gt;Every user has one primary hand when it comes to Kinect Interactions, although you can ignore this when using the &lt;strong&gt;InteractionStream&lt;/strong&gt; directly. The primary hand is the one which the user has raised first. If the user raises his / her other hand, the second hand is not considered active as long as the first hand is still raised. If the user lowers his first hand, then the second hand becomes primary (assuming it is still raised). In the picture above you can see that I have lifted my right hand first.&lt;/p&gt;

&lt;h3&gt;bool IsInteractive&lt;/h3&gt;

&lt;p&gt;To be honest, I have no idea what this property indicates. It seems like you can have both hands interactive at the same time, but it is possible to have a hand active, but not interactive. If you know what this property is about, please let me know in the comments, and I will update the post.&lt;/p&gt;

&lt;h3&gt;float PressExtent and bool IsPressed&lt;/h3&gt;

&lt;p&gt;Apart from the grip gesture, another gesture the &lt;strong&gt;InteractionStream&lt;/strong&gt; can help you with is the “Press” gesture. You can tell that a lot of consideration and thought went into the implementation of this seemingly simple gesture. You can press towards the screen, you can press forward in front of you, and it will still detect the pressing of the button fairly well. You can start from an arm close to your body or one which is almost entirely extended. You can perform the gesture quickly or with moderate speed. However, if you perform it slowly, the gesture will not be recognized, since it amounts to just pushing the PhIZ (Physical Interaction Zone – the area where your hand is considered as a pointer and mapped to the screen) a bit further from your body. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PressExtent&lt;/strong&gt; is proportional to how far along the press gesture the hand is. It is used to fill the hand cursor more and more to indicate that you are getting close to touching the button. When &lt;strong&gt;PressExtent&lt;/strong&gt; is 1 or higher, &lt;strong&gt;IsPressed&lt;/strong&gt; becomes true. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: I wish that the grip gesture would also have an IsGripping or IsHandClosed boolean for consistency’s sake. Or events, indicating the change of these states. Maybe in an upcoming SDK…&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;bool IsTracked&lt;/h3&gt;

&lt;p&gt;The name of the property indicates that this property shows whether the Kinect sensor can directly see the hand. The Skeleton engine has this information, but I have not been able to hide my hand so much that the IsTracked turned to false. &lt;/p&gt;

&lt;h3&gt;float RawX, RawY, RawZ, X, Y&lt;/h3&gt;

&lt;p&gt;The raw positions of the hand, relative to the Kinect. For the &lt;strong&gt;RawZ&lt;/strong&gt; coordinate, the 0 point is a little bit in front of your body, and the numbers increase as you extend your hand towards the sensor. The &lt;strong&gt;X&lt;/strong&gt; and &lt;strong&gt;Y&lt;/strong&gt; coordinates have the same values as the &lt;strong&gt;RawX &lt;/strong&gt;and &lt;strong&gt;RawY &lt;/strong&gt;coordinates. These coordinates seem to cover the PhIZ in front of the user. For &lt;strong&gt;X&lt;/strong&gt;, the numbers increase to the user’s right, and for &lt;strong&gt;Y&lt;/strong&gt; the numbers increase downwards. The origin moves with the user. The PhIZ seems to be between the raw coordinates (0,0,0) and (1,1,1). I am saying “seems to be”, since this is a bit gray area, where some documentation would be very useful. &lt;/p&gt;

&lt;h2&gt;Show Me the Codez!&lt;/h2&gt;

&lt;p&gt;Finally, here is the entire code of the &lt;strong&gt;InteractionFrameReady&lt;/strong&gt; event handler. Of course, the &lt;a href="http://sdrv.ms/Zt35WI" target="_blank"&gt;entire solution is also downloadable&lt;/a&gt;. &lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; Dictionary&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;, InteractionHandEventType&amp;gt; _lastLeftHandEvents = &lt;span class="kwrd"&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;, InteractionHandEventType&amp;gt;();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; Dictionary&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;, InteractionHandEventType&amp;gt; _lastRightHandEvents = &lt;span class="kwrd"&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;, InteractionHandEventType&amp;gt;();&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; InteractionStreamOnInteractionFrameReady(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, InteractionFrameReadyEventArgs args)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (var iaf = args.OpenInteractionFrame()) &lt;span class="rem"&gt;//dispose as soon as possible&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (iaf == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;        iaf.CopyInteractionDataTo(_userInfos);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;    StringBuilder dump = &lt;span class="kwrd"&gt;new&lt;/span&gt; StringBuilder();&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;    var hasUser = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;    &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (var userInfo &lt;span class="kwrd"&gt;in&lt;/span&gt; _userInfos)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;        var userID = userInfo.SkeletonTrackingId;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (userID == 0)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;            &lt;span class="kwrd"&gt;continue&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;        hasUser = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;        dump.AppendLine(&lt;span class="str"&gt;&amp;quot;User ID = &amp;quot;&lt;/span&gt; + userID);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;        dump.AppendLine(&lt;span class="str"&gt;&amp;quot;  Hands: &amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;        var hands = userInfo.HandPointers;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (hands.Count == 0)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;            dump.AppendLine(&lt;span class="str"&gt;&amp;quot;    No hands&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;        &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;            &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (var hand &lt;span class="kwrd"&gt;in&lt;/span&gt; hands)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;            {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt;                var lastHandEvents = hand.HandType == InteractionHandType.Left&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  34:  &lt;/span&gt;                                            ? _lastLeftHandEvents&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  35:  &lt;/span&gt;                                            : _lastRightHandEvents;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  36:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  37:  &lt;/span&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (hand.HandEventType != InteractionHandEventType.None)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  38:  &lt;/span&gt;                    lastHandEvents[userID] = hand.HandEventType;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  39:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  40:  &lt;/span&gt;                var lastHandEvent = lastHandEvents.ContainsKey(userID)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  41:  &lt;/span&gt;                                        ? lastHandEvents[userID]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  42:  &lt;/span&gt;                                        : InteractionHandEventType.None;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  43:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  44:  &lt;/span&gt;                dump.AppendLine();&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  45:  &lt;/span&gt;                dump.AppendLine(&lt;span class="str"&gt;&amp;quot;    HandType: &amp;quot;&lt;/span&gt; + hand.HandType);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  46:  &lt;/span&gt;                dump.AppendLine(&lt;span class="str"&gt;&amp;quot;    HandEventType: &amp;quot;&lt;/span&gt; + hand.HandEventType);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  47:  &lt;/span&gt;                dump.AppendLine(&lt;span class="str"&gt;&amp;quot;    LastHandEventType: &amp;quot;&lt;/span&gt; + lastHandEvent);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  48:  &lt;/span&gt;                dump.AppendLine(&lt;span class="str"&gt;&amp;quot;    IsActive: &amp;quot;&lt;/span&gt; + hand.IsActive);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  49:  &lt;/span&gt;                dump.AppendLine(&lt;span class="str"&gt;&amp;quot;    IsPrimaryForUser: &amp;quot;&lt;/span&gt; + hand.IsPrimaryForUser);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  50:  &lt;/span&gt;                dump.AppendLine(&lt;span class="str"&gt;&amp;quot;    IsInteractive: &amp;quot;&lt;/span&gt; + hand.IsInteractive);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  51:  &lt;/span&gt;                dump.AppendLine(&lt;span class="str"&gt;&amp;quot;    PressExtent: &amp;quot;&lt;/span&gt; + hand.PressExtent.ToString(&lt;span class="str"&gt;&amp;quot;N3&amp;quot;&lt;/span&gt;));&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  52:  &lt;/span&gt;                dump.AppendLine(&lt;span class="str"&gt;&amp;quot;    IsPressed: &amp;quot;&lt;/span&gt; + hand.IsPressed);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  53:  &lt;/span&gt;                dump.AppendLine(&lt;span class="str"&gt;&amp;quot;    IsTracked: &amp;quot;&lt;/span&gt; + hand.IsTracked);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  54:  &lt;/span&gt;                dump.AppendLine(&lt;span class="str"&gt;&amp;quot;    X: &amp;quot;&lt;/span&gt; + hand.X.ToString(&lt;span class="str"&gt;&amp;quot;N3&amp;quot;&lt;/span&gt;));&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  55:  &lt;/span&gt;                dump.AppendLine(&lt;span class="str"&gt;&amp;quot;    Y: &amp;quot;&lt;/span&gt; + hand.Y.ToString(&lt;span class="str"&gt;&amp;quot;N3&amp;quot;&lt;/span&gt;));&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  56:  &lt;/span&gt;                dump.AppendLine(&lt;span class="str"&gt;&amp;quot;    RawX: &amp;quot;&lt;/span&gt; + hand.RawX.ToString(&lt;span class="str"&gt;&amp;quot;N3&amp;quot;&lt;/span&gt;));&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  57:  &lt;/span&gt;                dump.AppendLine(&lt;span class="str"&gt;&amp;quot;    RawY: &amp;quot;&lt;/span&gt; + hand.RawY.ToString(&lt;span class="str"&gt;&amp;quot;N3&amp;quot;&lt;/span&gt;));&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  58:  &lt;/span&gt;                dump.AppendLine(&lt;span class="str"&gt;&amp;quot;    RawZ: &amp;quot;&lt;/span&gt; + hand.RawZ.ToString(&lt;span class="str"&gt;&amp;quot;N3&amp;quot;&lt;/span&gt;));&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  59:  &lt;/span&gt;            }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  60:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  61:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  62:  &lt;/span&gt;        tb.Text = dump.ToString();&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  63:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  64:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  65:  &lt;/span&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (!hasUser)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  66:  &lt;/span&gt;        tb.Text = &lt;span class="str"&gt;&amp;quot;No user detected.&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  67:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;And the MainWindow is simply a TextBox inside a ViewBox so that the text size follows the window’s size:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;InteractionStreamTest.MainWindow&amp;quot;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;        &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;        &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;        &lt;span class="attr"&gt;Title&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;MainWindow&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;350&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;525&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Viewbox&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;tb&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;FontFamily&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Lucida Console&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Initializing...&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Viewbox&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;h2&gt;Summary&lt;/h2&gt;

&lt;p&gt;I’ve shown you how you can get started with the &lt;strong&gt;InteractionStream&lt;/strong&gt; and acquire information about the hands of the users, detect active hands, pressing (&lt;strong&gt;IsPressed &lt;/strong&gt;and &lt;strong&gt;PressExtent&lt;/strong&gt;), and open / closed hands (&lt;strong&gt;HandEventType &lt;/strong&gt;and our custom &lt;strong&gt;LastHandEventType&lt;/strong&gt;). What I’ve shown here does not require WPF – you can use this from any .NET application, be it XNA, Windows Forms or even Command Line. &lt;/p&gt;

&lt;p&gt;Please share your thoughts, feedback, etc. in the comments!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=11206" width="1" height="1"&gt;</content><author><name>vbandi</name><uri>http://dotneteers.net/members/vbandi/default.aspx</uri></author><category term="Kinect" scheme="http://dotneteers.net/blogs/vbandi/archive/tags/Kinect/default.aspx" /><category term="Kinect Interactions" scheme="http://dotneteers.net/blogs/vbandi/archive/tags/Kinect+Interactions/default.aspx" /></entry><entry><title>Kinect Interaction with WPF Part II: Getting Started Easier</title><link rel="alternate" type="text/html" href="/blogs/vbandi/archive/2013/04/19/kinect-interaction-with-wpf-part-ii-getting-started-easier.aspx" /><id>/blogs/vbandi/archive/2013/04/19/kinect-interaction-with-wpf-part-ii-getting-started-easier.aspx</id><published>2013-04-19T14:27:33Z</published><updated>2013-04-19T14:27:33Z</updated><content type="html">&lt;p&gt;In the previous post of &lt;a href="http://dotneteers.net/blogs/vbandi/archive/tags/Kinect+Interactions/default.aspx" target="_blank"&gt;this series&lt;/a&gt;, I have introduced the Kinect for Windows SDK 1.7, and the key controls and concepts within its Kinect Interactions toolkit. If you have followed through &lt;a href="http://vbandi.dotneteers.net/blogs/vbandi/archive/2013/03/25/kinect-interactions-with-wpf-part-i-getting-started.aspx" target="_blank"&gt;that post&lt;/a&gt;, you have seen all the work and code you need to get the basics running. Most of the initialization code was biolerplate, and code that you can easily copy and paste into your own project.&lt;/p&gt;  &lt;p&gt;I have packaged up the initialization code into a UserControl called &lt;strong&gt;KinectChooserEx&lt;/strong&gt;, and wired up a couple of dependency properties. &lt;/p&gt;  &lt;p&gt;&lt;em&gt;Note: I could have inherited from KinectChooser instead of packaging it into a user control. But I ran into some serious strong name issues, and wanted more consistent naming for the properties, so it was better to hide some internal workings.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;The &lt;strong&gt;NearMode&lt;/strong&gt; property is a boolean value, and can be used to turn Near Mode on and off. Changing Near Mode also sets the &lt;strong&gt;EnableTrackingInNearRange&lt;/strong&gt; of the SkeletonStream. You will probably want to keep NearMode as false if you are using a Kinect for XBox sensor instead of a Kinect for Windows one. Otherwise the interaction engine works better at close range, so I have set &lt;strong&gt;NearMode &lt;/strong&gt;to be true by default.&lt;/p&gt;  &lt;p&gt;The other property is &lt;strong&gt;KinectSensor&lt;/strong&gt;, which contains null if no sensor is initialized, or a KinectSensor object if one is. &lt;/p&gt;  &lt;p&gt;Both of these properties are bindable. With &lt;strong&gt;KinectChooserEx, &lt;/strong&gt;you can finally get started with your own Kinect project purely in Blend, without writing a single line of code (at least for the interaction part). Here is a step by step tutorial on how to do this:&lt;/p&gt;  &lt;h2&gt;Create a New Project and Add KinectChooserEx.xaml and KinectChooserEx.xaml.cs&lt;/h2&gt;  &lt;p&gt;Create a new WPF project, and add the necessary references &lt;a href="http://dotneteers.net/blogs/vbandi/archive/2013/03/25/kinect-interactions-with-wpf-part-i-getting-started.aspx" target="_blank"&gt;as described in my previous post&lt;/a&gt;. Drag and drop the KinectChooserEx.xaml and KinectChooserEx.xaml.cs files from Explorer into the project. You will also want to add the KinectInteraction170_32.dll and KinectInteraction170_64.dll files at this point (again, see my previous post).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_52C61A8B.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_19430A94.png" width="608" height="484" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Make sure that the project compiles. &lt;/p&gt;  &lt;h2&gt;&lt;/h2&gt;  &lt;h2&gt;Add KinectChooserEx to the MainPage&lt;/h2&gt;  &lt;p&gt;You should be able to find the KinectChooserEx user control in Blend now. Press CTRL+. or the &amp;gt;&amp;gt; button on the left toolbar to bring up the Assets panel. If you start typing “Kinect”, you should see the KinectChooserEx control:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_31D2A7E4.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_3C8FFF39.png" width="627" height="257" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Drag and drop it onto the design surface.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_2A473877.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_030CEF42.png" width="433" height="298" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Position it so that it looks a bit better. I am setting the HorizontalAlignment and VerticalAlignment properties so that the control will have adequate space to expand (remember, if you move the mouse over it, KinectChooser shows error status and explanation).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_42D6D5C7.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_69A4EC07.png" width="319" height="115" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You should also see a new Property Category called “Kinect”, with a lonely &lt;strong&gt;NearMode&lt;/strong&gt; property, set to true by default:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_7B817FD4.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_0953C5D0.png" width="337" height="82" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h2&gt;&lt;/h2&gt;  &lt;h2&gt;Adding a KinectRegion&lt;/h2&gt;  &lt;p&gt;As I showed in the last post, the KinectRegion control is the heart of the entire Kinect Interaction experience. So, let’s add one of these to our project. Again, just add it from the Assets panel, and place it so that it occupies most of the screen:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_3021DC10.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_41FE6FDD.png" width="244" height="166" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;To make the KinectRegion work, it needs a KinectSensor object. This is what &lt;strong&gt;KinectChooserEx &lt;/strong&gt;can provide, so let’s wire up this binding. Select the KinectRegion control, find its KinectSensor property, and click the little property peg:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_16B9D8D6.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_087B5FE6.png" width="341" height="486" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select Bind to Element and click on the KinectChooserEx control in either the designer area or the Object tree. Blend automatically chooses the KinectChooserEx’s KinectSensor property, since it has the right type. All we have to do is press the OK button.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_4845466B.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_56178C66.png" width="491" height="205" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h2&gt;Adding a KinectUserViewer control&lt;/h2&gt;  &lt;p&gt;Similarly, we can add a &lt;strong&gt;KinectUserViewer&lt;/strong&gt; control to the application. I have added it &lt;strong&gt;above&lt;/strong&gt; the &lt;strong&gt;KinectRegion&lt;/strong&gt;, so that the hand cursor will be in front of the user’s silhouette – but otherwise I allowed to take up the entire screen. It is up to you – you may want to put it into the top, or one of the corners.&lt;/p&gt;  &lt;p&gt;You have to bind the KinectUserViewer control’s KinectRegion property to the KinectRegion we created earlier. Binding the KinectSensor property will not work. Unfortunately, it seems like the KinectRegion property is not shown in Blend, so we have to do this part manually in XAML. &lt;/p&gt;  &lt;p&gt;First, let’s add a name to the KinectRegion control. I called it “region” for now. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_67F42033.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_75C6662E.png" width="329" height="64" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Next, select the KinectUserViewer control, and open the split view. Type the following within the XAML tag:&lt;/p&gt;  &lt;p&gt;k:KinectRegion.KinectRegion=&amp;quot;{Binding ElementName=region}&amp;quot;&lt;/p&gt;  &lt;p&gt;So, the entire XAML tag looks like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_6EA729B6.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_6787ED3E.png" width="585" height="29" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h2&gt;&lt;/h2&gt;  &lt;h2&gt;Let’s See it Work!&lt;/h2&gt;  &lt;p&gt;Press F5, and Blend should launch the application. If all is well, you should see something like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_476CE081.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_0736C707.png" width="244" height="164" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;If the application does not start or crash, please load the solution up in Visual Studio and check the error message. The &lt;a href="http://vbandi.dotneteers.net/blogs/vbandi/archive/2013/03/25/kinect-interactions-with-wpf-part-i-getting-started.aspx" target="_blank"&gt;first post in this series&lt;/a&gt; has some troubleshooting info for the most common issues.&lt;/p&gt;  &lt;h2&gt;Using the Near Mode&lt;/h2&gt;  &lt;p&gt;For fun, we can add a checkbox that controls the Near Mode of the Kinect Sensor. All you have to do is bind its IsChecked property to the NearMode property of the &lt;strong&gt;KinectChooserEx&lt;/strong&gt; control, and make sure the binding is set to be a TwoWay binding:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_19135AD4.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_66AF8754.png" width="447" height="316" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now you can control whether you want near mode on or off. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_5466C092.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_7F3F24A4.png" width="529" height="354" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_6CF65DE2.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_2CC04468.png" width="529" height="354" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;As you can see above, when near mode is off, it cannot detect my left hand anymore even though I moved it back a bit between the two screenshots. &lt;/p&gt;  &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;I hope you will find this little Blend + Kinect tutorial and the KinectChooserEx control useful. Feel free to enhance it, add more properties, features, bugfixes, etc. &lt;a href="http://sdrv.ms/117qGxo" target="_blank"&gt;You can download the code from here&lt;/a&gt; (it also contains the project from the previous article). Please keep the feedback coming!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=11193" width="1" height="1"&gt;</content><author><name>vbandi</name><uri>http://dotneteers.net/members/vbandi/default.aspx</uri></author><category term="Expression Blend" scheme="http://dotneteers.net/blogs/vbandi/archive/tags/Expression+Blend/default.aspx" /><category term="Kinect" scheme="http://dotneteers.net/blogs/vbandi/archive/tags/Kinect/default.aspx" /><category term="Kinect Interactions" scheme="http://dotneteers.net/blogs/vbandi/archive/tags/Kinect+Interactions/default.aspx" /></entry><entry><title>Kinect Interactions with WPF - Part I: Getting Started</title><link rel="alternate" type="text/html" href="/blogs/vbandi/archive/2013/03/25/kinect-interactions-with-wpf-part-i-getting-started.aspx" /><id>/blogs/vbandi/archive/2013/03/25/kinect-interactions-with-wpf-part-i-getting-started.aspx</id><published>2013-03-25T14:24:22Z</published><updated>2013-03-25T14:24:22Z</updated><content type="html">&lt;h1&gt;Introduction&lt;/h1&gt;  &lt;p&gt;Microsoft has &lt;a href="http://blogs.msdn.com/b/kinectforwindows/archive/2013/03/16/kinect-for-windows-announces-new-version-of-sdk-coming-march-18.aspx" target="_blank"&gt;recently released&lt;/a&gt; V1.7 of the Kinect for Windows SDK. And they immediately made a mistake – there are so many new and awesome stuff in it, that it should be called 2.0 :)&lt;/p&gt;  &lt;p&gt;The 1.7 SDK focuses on two key new features: Kinect Fusion and Kinect Interactions. Kinect Fusion is essentially a 3D scanner that enabled developers to create accurate 3D renderings in real time. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image69_5F00_76F2A375.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image69_5F00_thumb_5F00_3A5AA4D8.png" width="446" height="166" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Kinect Fusion. Source: &lt;a href="http://blogs.msdn.com/b/kinectforwindows/archive/2013/03/16/kinect-for-windows-announces-new-version-of-sdk-coming-march-18.aspx" target="_blank"&gt;Kinect for Windows blog&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;While Kinect Fusion is beyond awesome, this blog post series focuses on the other big new feature of the Kinect for Windows (K4W) SDK 1.7: &lt;strong&gt;Kinect Interactions&lt;/strong&gt;. Kinect Interactions allow developers to create interactive applications with a new, well-designed and ergonomically friendlier interaction language than before. The Kinect SDK can now detect a “push towards the screen” gesture to activate buttons, and this is the recommended “activate” gesture now instead of the old “hover, wait until the circle fills and its pressed” gesture.&lt;/p&gt;  &lt;p&gt;Browsing lists larger than a dozen or so items has been even more difficult using Kinect. The recommended solution was to implement a “swipe from side” gesture, which paged through items on the screen. Here is such a list, straight from my XBox:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/WP_5F00_20130322_5F00_002_5F00_15C91754.jpg"&gt;&lt;img title="WP_20130322_002" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="WP_20130322_002" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/WP_5F00_20130322_5F00_002_5F00_thumb_5F00_155CE45F.jpg" width="453" height="281" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You can see that the list has 358 games, and 5 of them are visible at the same time. To get through even half of this list, you would have to perform the swipe gesture 36 times! This is extremely slow, frustrating and physically exhausting. &lt;/p&gt;  &lt;p&gt;The latest K4W SDK solves this issue by differentiating between an open and a closed hand. When you close your hand, you “grip” whatever’s underneath it (such as a scrollviewer), and then you can move your hand to scroll. If you release the scroller while your hand is still moving, the scrolling keeps happening – similarly to the inertia scroll you are already used to on touch devices. You can close your hand again at any time, and stop the inertia – again, as you expected. &lt;/p&gt;  &lt;p&gt;In this post, I will help you to get started with Kinect Interactions by creating a Hello World WPF app that uses the features mentioned above. In later posts, I will dive deeper into the Kinect Interactions SDK, show you how to customize the existing controls, create new ones and go deep into the lower levels of the InteractionStream to invent new ways of interacting with your app. But first, let’s see how you can get started with Kinect Interactions today!&lt;/p&gt;  &lt;p&gt;Note: I am assuming that you are familiar with C# and WPF for this article series. &lt;/p&gt;  &lt;h1&gt;First Things First – Download and Install the bits&lt;/h1&gt;  &lt;p&gt;Assuming you already have a Kinect for Windows device (or at least a Kinect for XBox one, which doesn’t support Near Mode, but can be legally used for development, but not “going live”), the next step is to install the SDK. Head over to &lt;a href="http://www.microsoft.com/en-us/kinectforwindows/develop/developer-downloads.aspx" target="_blank"&gt;Kinect Developer Downloads&lt;/a&gt; and download and install the SDK, and then the Kinect for Windows Developer Toolkit. After everything is done, launch the Kinect Developer Toolkit Browser from your start menu, and verify that the computer sees your Kinect by launching the “Kinect Explorer – WPF” sample. If all’s good, you can play a little with the samples called “Controls Basics – WPF” and “Interaction Gallery – WPF” to experience Kinect Interactions for yourself.&lt;/p&gt;  &lt;h2&gt;&lt;/h2&gt;  &lt;h1&gt;Create the Project&lt;/h1&gt;  &lt;p&gt;First, create a new WPF Application project called “GettingStarted”. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_350BBE27.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_7F92FC01.png" width="477" height="331" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Add the following references: &lt;/p&gt;  &lt;p&gt;From the &lt;em&gt;C:\Program Files\Microsoft SDKs\Kinect\v1.7\Assemblies\&lt;/em&gt; folder, add &lt;em&gt;Microsoft.Kinect.dll.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;From the &lt;em&gt;C:\Program Files\Microsoft SDKs\Kinect\Developer Toolkit v1.7.0\Assemblies\ &lt;/em&gt;folder, add &lt;em&gt;Kinect.Toolkit.dll&lt;/em&gt;, &lt;em&gt;Kinect.Toolkit.Controls.dll &lt;/em&gt;and &lt;em&gt;Kinect.Toolkit.Interaction.dll&lt;/em&gt;&lt;/p&gt;  &lt;h1&gt;Initializing the Kinect Sensor with KinectSensorChooser&lt;/h1&gt;  &lt;p&gt;The first control we will use from the Microsoft.Kinect.Toolkit.Controls namespace is the &lt;strong&gt;KinectSensorChooserUI&lt;/strong&gt;. It is a fairly boring control, but it is nonetheless important: it indicates the status of the Attached Kinect Sensor, and can inform the user if the sensor is unplugged, plugged into the wrong USB port, etc. &lt;/p&gt;  &lt;p&gt;In the MainView.xaml, add the following namespace:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;xmlns:k=&lt;span class="str"&gt;&lt;a href="http://schemas.microsoft.com/kinect/2013"&gt;http://schemas.microsoft.com/kinect/2013&lt;/a&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;style&gt;







.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;Then add the KinectSensorChooserUI control to the main grid:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;k:KinectSensorChooserUI&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Top&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;sensorChooserUi&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;We also need to initialize the KinectSensorChooser from the codebehind with some boilerplate code (I took these from the K4W samples).&lt;/p&gt;

&lt;p&gt;Add a private field to the MainWindow codebehind:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; KinectSensorChooser sensorChooser;&lt;/pre&gt;
&lt;style&gt;







.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Set up an event handler for the OnLoaded event in the MainWindow constructor (or in XAML, as you wish):&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; MainWindow()
{
    InitializeComponent();
    Loaded += OnLoaded;
}&lt;/pre&gt;
&lt;style&gt;







.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;And create the OnLoaded event handler:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnLoaded(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs routedEventArgs) 
{ 
    &lt;span class="kwrd"&gt;this&lt;/span&gt;.sensorChooser = &lt;span class="kwrd"&gt;new&lt;/span&gt; KinectSensorChooser(); 
    &lt;span class="kwrd"&gt;this&lt;/span&gt;.sensorChooser.KinectChanged += SensorChooserOnKinectChanged; 
    &lt;span class="kwrd"&gt;this&lt;/span&gt;.sensorChooserUi.KinectSensorChooser = &lt;span class="kwrd"&gt;this&lt;/span&gt;.sensorChooser; 
    &lt;span class="kwrd"&gt;this&lt;/span&gt;.sensorChooser.Start(); 
}&lt;/pre&gt;
&lt;style&gt;







.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;If a sensor is chosen or got initialized, the code above will invoke the SensorChooserOnKinectChanged event handler. Let’s keep this one simple for now, just add a MessageBox to indicate things happened: &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SensorChooserOnKinectChanged(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, KinectChangedEventArgs args) 
{ 
    MessageBox.Show(args.NewSensor == &lt;span class="kwrd"&gt;null&lt;/span&gt; ? &lt;span class="str"&gt;&amp;quot;No Kinect&amp;quot;&lt;/span&gt; : args.NewSensor.Status.ToString()); 
}&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&amp;#160;&lt;/pre&gt;
&lt;style&gt;







.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Now we can run the app. First, let’s see what happens if there are no Kinects connected to the computer:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_14184B80.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_0CF90F08.png" width="529" height="354" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, sensorChooser.Kinect is null in this case.&lt;/p&gt;

&lt;p&gt;If the mouse is moved over the little box above, it expands, and shows a more detailed help on the required action. Nice!&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_05D9D290.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_17B6665D.png" width="529" height="354" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The help link takes you to a &lt;a href="http://support.xbox.com/en-US/kinect-for-windows/kinect-for-windows-info" target="_blank"&gt;Microsoft web page&lt;/a&gt; about Kinect for Windows.&lt;/p&gt;

&lt;p&gt;If you connect the Kinect Sensor now, the KinectSensorChooserUI will switch to an “Initializing” mode: &lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_5375FF10.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_37654025.png" width="529" height="354" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;With the mouse hovering over it:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_7324D8D8.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_3E1849A8.png" width="529" height="354" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;… and after a while, the Kinect sensor will be initialized, and the event handler with the MessageBox will get called:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_4BEA8FA3.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_72B8A5E3.png" width="529" height="354" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;After this, the Kinect chooser UI disappears until there’s a problem.&lt;/p&gt;

&lt;p&gt;The KinectChooserUI control can also warn the user to move the Kinect to another USB port, check the power supply, etc. Here are the possible statuses:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;enum&lt;/span&gt; KinectStatus 
{ 
  Undefined, 
  Disconnected, 
  Connected, 
  Initializing, 
  Error, 
  NotPowered, 
  NotReady, 
  DeviceNotGenuine, 
  DeviceNotSupported, 
  InsufficientBandwidth, 
}&lt;/pre&gt;

&lt;h3&gt;&lt;style&gt;







.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/h3&gt;

&lt;h2&gt;&lt;/h2&gt;

&lt;h2&gt;Setting up the Kinect for Interactions&lt;/h2&gt;

&lt;p&gt;Now that we made sure that we have a properly connected Kinect sensor, it’s time to get it to work with some more boilerplate code. Let’s replace the temporary SensorChooserOnKinectChanged event handler with the real stuff:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SensorChooserOnKinectChanged(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, KinectChangedEventArgs args)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    &lt;span class="kwrd"&gt;bool&lt;/span&gt; error = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (args.OldSensor != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;        &lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;            args.OldSensor.DepthStream.Range = DepthRange.Default;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;            args.OldSensor.SkeletonStream.EnableTrackingInNearRange = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;            args.OldSensor.DepthStream.Disable();&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;            args.OldSensor.SkeletonStream.Disable();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;        &lt;span class="kwrd"&gt;catch&lt;/span&gt; (InvalidOperationException)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;            &lt;span class="rem"&gt;// KinectSensor might enter an invalid state while enabling/disabling streams or stream features.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;            &lt;span class="rem"&gt;// E.g.: sensor might be abruptly unplugged.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;            error = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (args.NewSensor != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;        &lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;            args.NewSensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;            args.NewSensor.SkeletonStream.Enable();&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;            &lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;            {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;                args.NewSensor.DepthStream.Range = DepthRange.Near;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;                args.NewSensor.SkeletonStream.EnableTrackingInNearRange = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;                args.NewSensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt;            }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  34:  &lt;/span&gt;            &lt;span class="kwrd"&gt;catch&lt;/span&gt; (InvalidOperationException)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  35:  &lt;/span&gt;            {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  36:  &lt;/span&gt;                &lt;span class="rem"&gt;// Non Kinect for Windows devices do not support Near mode, so reset back to default mode.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  37:  &lt;/span&gt;                args.NewSensor.DepthStream.Range = DepthRange.Default;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  38:  &lt;/span&gt;                args.NewSensor.SkeletonStream.EnableTrackingInNearRange = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  39:  &lt;/span&gt;                error = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  40:  &lt;/span&gt;            }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  41:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  42:  &lt;/span&gt;        &lt;span class="kwrd"&gt;catch&lt;/span&gt; (InvalidOperationException)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  43:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  44:  &lt;/span&gt;            error = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  45:  &lt;/span&gt;            &lt;span class="rem"&gt;// KinectSensor might enter an invalid state while enabling/disabling streams or stream features.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  46:  &lt;/span&gt;            &lt;span class="rem"&gt;// E.g.: sensor might be abruptly unplugged.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  47:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  48:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  49:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style&gt;







.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;This code handles properly Shutting down the old Kinect Sensor (you can have multiple sensors connected to the PC) and starts up the Depth- and Skeleton streams for the new one. In Lines 31 and 32, near mode and seated skeleton tracking are turned on – these are optional, but I found them useful for my little developer corner.&lt;/p&gt;

&lt;h1&gt;The Kinect Region&lt;/h1&gt;

&lt;p&gt;The last step before we can see something from Kinect Interactions is to add a &lt;strong&gt;KinectRegion &lt;/strong&gt;to the XAML. KinectRegion is the key element of Kinect Interactions on WPF: it is the screen area where interactive elements are placed and can be manipulated. KinectRegion is also responsible for displaying and moving the hand cursor. An application can have multiple KinectRegions, but they cannot be nested. Each KinectRegion can have their own respective Kinect sensor.&lt;/p&gt;

&lt;p&gt;Let’s add a KinectRegion to the main Grid of the MainWindow, thus making it stretch the entire window:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;k:KinectRegion&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;kinectRegion&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; 
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;k:KinectRegion&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;style&gt;






.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Also, let’s make sure that the KinectSensor property of this KinectRegion is set to the actual Kinect by adding the following at the end of the SensorChooserOnKinectChanged event:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (!error) 
    kinectRegion.KinectSensor = args.NewSensor; &lt;/pre&gt;
&lt;style&gt;






.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;If you run the app now, you get one more error: &lt;/p&gt;

&lt;p&gt;“Unable to invoke library &amp;#39;KinectInteraction170_32.dll&amp;#39;.”&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image24_5F00_3DAC16B3.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image24_5F00_thumb_5F00_12677FAC.png" width="543" height="366" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;This is a common problem with Kinect beginners. The dll mentioned can be a bit tricky to find. The simplest way is to install the Controls Basics – WPF source code from the Developer Toolkit Browser (press the Install button) – or just download the sample project for this article (as long as you are targeting the same, 1.7 Kinect SDK). &lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_3620A746.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_3CD3B0C9.png" width="555" height="84" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Go to the AnyCPU.Debug folder of the sample’s installation directory and copy the KinectInteraction170_32.dll and KinectInteraction170_64.dll files to your project’s output directory. Now the app should run. Note: you may have to wait as much as 20 seconds for the Kinect Sensor to initialize. During this process, your application will not respond and will show a wait cursor if you move the mouse over it.&lt;/p&gt;

&lt;p&gt;If all is OK, you should be able to raise one of your hands in front of you, and see a Hand Cursor representing it in your Main Window. You may have to wiggle around a bit so that the Kinect Sensor can detect you as a user.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image27_5F00_7C9D974E.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image27_5F00_thumb_5F00_751227E1.png" width="558" height="325" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;For the screenshot above, I have also launched Kinect Studio. The Depth Viewer and Kinect Studio windows are not part of our application. Kinect Studio helps monitor the data our application receives. It can also record the Kinect’s output and allows you to play back the same user actions later. You can learn more about Kinect Studio &lt;a href="http://msdn.microsoft.com/en-us/library/hh855389.aspx" target="_blank"&gt;on MSDN&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;User Viewer&lt;/h1&gt;

&lt;p&gt;The next control we discuss is the Microsoft.Kinect.Toolkit.Controls.KinectUserViewer. Let’s add it to the main Grid:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;k:KinectUserViewer&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Top&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt; &lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="attr"&gt;k:KinectRegion&lt;/span&gt;.&lt;span class="attr"&gt;KinectRegion&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{Binding ElementName=kinectRegion}&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;100&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&amp;#160;&lt;/pre&gt;
&lt;style&gt;






.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;The &lt;strong&gt;KinectUserViewer &lt;/strong&gt;displays the depth pixels that belong to an identified user or users. You can use the KinectUserViewer control to make sure that the Kinect SDK “sees” you as a human and is able to separate you from the surroundings. If you see nothing in the KinectUserViewer (after the Kinect initialization has finished), it means that the Kinect is not tracking you, it hasn’t identified you as a person yet. Try to move around, and remember that you need to be at least a meter (or even more) away from the sensor for it to detect you.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_2FF95AAB.png"&gt;&lt;img title="image" style="display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_41D5EE78.png" width="244" height="165" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_39DE4C16.png"&gt;&lt;img title="image" style="display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_32BF0F9E.png" width="244" height="165" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h1&gt;&lt;/h1&gt;

&lt;h1&gt;Interactive Controls&lt;/h1&gt;

&lt;p&gt;So far we managed to notify the user of the Kinect Sensor’s state, put a hand cursor on the screen that followed the user’s hand and to show an outline of the user. It’s time for the hand to actually do something! The first such something is going to be pressing a button.&lt;/p&gt;

&lt;h2&gt;The KinectTileButton&lt;/h2&gt;

&lt;p&gt;The KinectTileButton is one of the simplest controls available. It resembles a Windows 8-style tile with a template-able label and a Content that is just like the content of the regular Button control. Here is a very simple declaration of the KinectTileButton that should be put inside the main Grid of MainWindow.xaml:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;k:KinectTileButton&lt;/span&gt; &lt;span class="attr"&gt;Label&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Press me!&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Click&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ButtonOnClick&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;k:KinectTileButton&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style&gt;




.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;To handle the button’s Click event, let’s just do a simple MessageBox:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ButtonOnClick(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e) 
{ 
    MessageBox.Show(&lt;span class="str"&gt;&amp;quot;Well done!&amp;quot;&lt;/span&gt;); 
}&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&amp;#160;&lt;/pre&gt;
&lt;style&gt;




.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;The KinectButton control has a nice Kinect-purple color by default. Here’s what it looks like: (Note: I’ve changed window height and width to 600x500 for more space)&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image42_5F00_598D25DE.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image42_5F00_thumb_5F00_60402F61.png" width="598" height="501" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;If you move the hand cursor over the KinectButton it grows a little to indicate the “hover” state. The hand cursor also changes subtly.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image45_5F00_721CC32E.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image45_5F00_thumb_5F00_26BD1F6A.png" width="602" height="501" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;If you start to move your hand towards the screen (attempting to perform the “press” gesture), the hand will begin to fill up with a purple circular pattern. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image48_5F00_5195837C.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image48_5F00_thumb_5F00_58488CFF.png" width="605" height="504" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;When you actually press the button, the button will play some visual effects, and the cursor’s fill color will change again. Then, our ugly little MessageBox will show up, indicating that the button has indeed been pressed, and the proper event handler was called. Nice!&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image51_5F00_18127385.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image51_5F00_thumb_5F00_1EC57D08.png" width="603" height="508" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;&lt;/h2&gt;

&lt;h2&gt;The KinectCircleButton&lt;/h2&gt;

&lt;p&gt;The next button type works a lot like the KinectTileButton. However, in order to show it, we first need to change the existing xaml a little bit. The KinectRegion is a ContentControl, which means it can only have one child. Luckily, this Child can be a control that in turn can contain multiple children – such as a Grid or a StackPanel. For now, we will need to surround the existing KinectTileButton with a Grid. I’ve also moved the KinectTileButton to the left side to leave some space for the &lt;strong&gt;KinectCircleButton&lt;/strong&gt; we are about to add. The button has a content (which, again can be anything, including an image or a much more complex element), and a Label. The KinectCircleButton resembles the RoundButton of Windows Phone. Let’s add it to the Grid we just added inside the Kinectregion:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&amp;lt;k:KinectCircleButton Label=&lt;span class="str"&gt;&amp;quot;Circle&amp;quot;&lt;/span&gt; HorizontalAlignment=&lt;span class="str"&gt;&amp;quot;Right&amp;quot;&lt;/span&gt; Height=&lt;span class="str"&gt;&amp;quot;200&amp;quot;&lt;/span&gt; Click=&lt;span class="str"&gt;&amp;quot;ButtonOnClick&amp;quot;&lt;/span&gt;&amp;gt;Hi&amp;lt;/k:KinectCircleButton&amp;gt;&lt;/pre&gt;
&lt;style&gt;




.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;This is what the application looks like now: &lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image54_5F00_778B33D2.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image54_5F00_thumb_5F00_7E3E3D55.png" width="599" height="498" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Moving the hand above the KinectCircleButton, we can see that it also has an “over” state, and changes the look of the hand just like the KinectTileButton did. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image57_5F00_5703F420.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image57_5F00_thumb_5F00_5DB6FDA3.png" width="596" height="504" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Moving the hand towards the screen: &lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image60_5F00_4B6E36E1.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image60_5F00_thumb_5F00_562B8E36.png" width="595" height="504" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;… and finally pressing it: &lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image66_5F00_15F574BC.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image66_5F00_thumb_5F00_1CA87E3F.png" width="598" height="502" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;It is good to know that these interactive elements also work with the mouse. This way you can test the app itself without using Kinect. Kinect initialization can takes 15 seconds or more, so to test your app’s logic, UI and flow, you may even want to disconnect the Kinect to get the app started faster.&lt;/p&gt;

&lt;h1&gt;&lt;/h1&gt;

&lt;h1&gt;They See Me Scrollin’&lt;/h1&gt;

&lt;p&gt;As I said in the Introduction, browsing a big list of items and selecting the one you want has always been difficult with Kinect – but with the latest Kinect SDK, this situation is vastly improved. The key is the third (and last) out-of-the-box control of the 1.7 SDK: the &lt;strong&gt;KinectScrollViewer&lt;/strong&gt;. Let’s place a KinectScrollViewer at the bottom of our window by pasting the code below into the Grid inside the KinectRegion:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;k:KinectScrollViewer&lt;/span&gt; &lt;span class="attr"&gt;VerticalScrollBarVisibility&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Disabled&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;HorizontalScrollBarVisibility&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Auto&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Bottom&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt; &lt;span class="attr"&gt;Orientation&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Horizontal&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;scrollContent&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;k:KinectScrollViewer&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;style&gt;




.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;This looks exactly like a standard WPF ScrollViewer. It even has a StackPanel called “scrollContent”, and these two controls are set up to scroll horizontally. Let’s fill up the StackPanel with some KinectCircleButtons. For this, add the following lines to the OnLoaded event handler in the code behind:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;//fill scroll content&lt;/span&gt;
&lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 1; i &amp;lt; 20; i++)
{
    var button = &lt;span class="kwrd"&gt;new&lt;/span&gt; KinectCircleButton
                        {
                            Content = i,
                            Height = 200
                        };

    &lt;span class="kwrd"&gt;int&lt;/span&gt; i1 = i;
    button.Click +=
        (o, args) =&amp;gt; MessageBox.Show(&lt;span class="str"&gt;&amp;quot;You clicked button #&amp;quot;&lt;/span&gt; + i1);

    scrollContent.Children.Add(button);
}&lt;/pre&gt;
&lt;style&gt;




.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;If we run the application now, this is what it looks like: &lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_756E3509.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_4E33EBD4.png" width="557" height="338" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Moving the hand over the scrollable area, it changes color: &lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_3BEB2512.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_5B99FEDA.png" width="555" height="337" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The trick now is to close your hand and make a fist, as if you were grabbing something. The hand cursor will change, indicating that you indeed grabbed onto the KinectScrollViewer:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_345FB5A5.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_33F382B0.png" width="561" height="338" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Now you can move your hand, and the KinectScrollViewer will “stick to it”, much like when you scroll a list on a touch device, such as a phone or a tablet. If you open your hand, you will release the KinectScrollViewer. If you push your hand forward, you can select easily one of the items in the list and get the corresponding MessageBox:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_21AABBEE.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_415995B6.png" width="574" height="332" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h1&gt;&lt;/h1&gt;

&lt;h1&gt;Download&lt;/h1&gt;

&lt;p&gt;You can download the demo project for this article &lt;a href="http://sdrv.ms/10tWqi9" target="_blank"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;h1&gt;Summary&lt;/h1&gt;

&lt;p&gt;In this post, I’ve introduced you to the basics to get started with a Kinect Interactions application – getting the Kinect sensor up and running, defining a KinectRegion, adding buttons and scrollable areas to it. &lt;/p&gt;

&lt;p&gt;In the next posts of this series, I will dive deeper into the world of Kinect Interactions. We will dive deeper into the – unfortunately very sparsely documented – controls I discussed above, and see the customization options they offer. And finally, going deeper into the rabbit hole, we will examine the low level Interaction Stream. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=11148" width="1" height="1"&gt;</content><author><name>vbandi</name><uri>http://dotneteers.net/members/vbandi/default.aspx</uri></author><category term="Kinect" scheme="http://dotneteers.net/blogs/vbandi/archive/tags/Kinect/default.aspx" /><category term="Kinect Interactions" scheme="http://dotneteers.net/blogs/vbandi/archive/tags/Kinect+Interactions/default.aspx" /></entry><entry><title>Windows Phone Performance – Part 8 of many: Lumia 620 performance</title><link rel="alternate" type="text/html" href="/blogs/vbandi/archive/2013/03/16/windows-phone-performance-part-7-of-many-lumia-620-performance.aspx" /><id>/blogs/vbandi/archive/2013/03/16/windows-phone-performance-part-7-of-many-lumia-620-performance.aspx</id><published>2013-03-16T20:43:58Z</published><updated>2013-03-16T20:43:58Z</updated><content type="html">&lt;p&gt;&lt;em&gt;In this post, I’ll take a look at the performance of the Nokia Lumia 620 from a developer’s point of view. This post is part of my &lt;a href="http://dotneteers.net/blogs/vbandi/archive/tags/WP+Performance/default.aspx" target="_blank"&gt;Windows Phone Performance series&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;HUGE thanks to &lt;a href="http://dotnetbyexample.blogspot.hu/" target="_blank"&gt;Joost von Schaik&lt;/a&gt; for performing the tests in this article. Since I don’t have access to a Lumia 620, without him, this post would not have been possible.&lt;/em&gt;&lt;/p&gt;  &lt;h2&gt;&lt;/h2&gt;  &lt;h2&gt;The Nokia Lumia 620&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_48693FAA.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;margin:0px;border-left:0px;display:inline;" border="0" alt="image" align="right" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_4C075A87.png" width="210" height="244" /&gt;&lt;/a&gt; The 620 is the almost-smallest member of Nokia’s Windows Phone 8 family yet. The 520 is smaller, but not yet available. The 620 is a great phone, and provides a good Windows Phone 8 experience for a fraction of the price of its bigger brothers, such as the &lt;a href="http://dotneteers.net/blogs/vbandi/archive/2013/01/10/windows-phone-performance-part-7-of-many-lumia-820-performance.aspx" target="_blank"&gt;820&lt;/a&gt; and the &lt;a href="http://dotneteers.net/blogs/vbandi/archive/2012/12/27/windows-phone-performance-part-6-of-many-nokia-lumia-920-performance.aspx" target="_blank"&gt;920&lt;/a&gt; (both of which we have tested earlier).&lt;/p&gt;  &lt;p&gt;The 620 has a dual core Snapdragon S4 processor. This is not the same as the ones found in the 920 (MSM8960T) and the 820 (MSM8960) though (both of which run at 1.5GHz). The 620 has an MSM8227, running at 1 GHz, and an Adreno 305 GPU. The screen has 800x480 pixels (same as the 820, but lower than the 920). Another notable difference is that the 620 has 512 MBytes of RAM onboard. While this may affect multitasking and other end-user features, our tests were not impacted by the lower amount of memory.&lt;/p&gt;  &lt;p&gt;Because of its low price and attractive design, the 620 is expected to sell very well in countries such as India, Chine and Eastern Europe (just like the 610 did).&lt;/p&gt;  &lt;h2&gt;&lt;/h2&gt;  &lt;h2&gt;Application Loading / CPU Performance&lt;/h2&gt;  &lt;p&gt;For this test, I am using the same test I used for the other phones, from the second part of this series: &lt;a title="It’s Full of Stars!" href="http://vbandi.dotneteers.net/blogs/vbandi/archive/2012/02/18/windows-phone-performance-part-2-of-many-it-s-full-of-stars.aspx"&gt;It’s Full of Stars!&lt;/a&gt;&lt;/p&gt;  &lt;table cellspacing="0" cellpadding="0"&gt;     &lt;tr&gt;       &lt;td&gt;&lt;strong&gt;Number of Stars&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Lumia 620&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Optimus 7&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Lumia 800&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Lumia 920&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Lumia 820&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;100&lt;/td&gt;        &lt;td&gt;310&lt;/td&gt;        &lt;td&gt;399&lt;/td&gt;        &lt;td&gt;347&lt;/td&gt;        &lt;td&gt;164&lt;/td&gt;        &lt;td&gt;497&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;1000&lt;/td&gt;        &lt;td&gt;727&lt;/td&gt;        &lt;td&gt;1133&lt;/td&gt;        &lt;td&gt;846&lt;/td&gt;        &lt;td&gt;449&lt;/td&gt;        &lt;td&gt;539&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;2000&lt;/td&gt;        &lt;td&gt;1119&lt;/td&gt;        &lt;td&gt;1882&lt;/td&gt;        &lt;td&gt;1357&lt;/td&gt;        &lt;td&gt;711&lt;/td&gt;        &lt;td&gt;723&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;5000&lt;/td&gt;        &lt;td&gt;2425&lt;/td&gt;        &lt;td&gt;4258&lt;/td&gt;        &lt;td&gt;3007&lt;/td&gt;        &lt;td&gt;1557&lt;/td&gt;        &lt;td&gt;1465&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;10000&lt;/td&gt;        &lt;td&gt;4569&lt;/td&gt;        &lt;td&gt;8348&lt;/td&gt;        &lt;td&gt;5792&lt;/td&gt;        &lt;td&gt;2913&lt;/td&gt;        &lt;td&gt;2899&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;15000&lt;/td&gt;        &lt;td&gt;6887&lt;/td&gt;        &lt;td&gt;12183&lt;/td&gt;        &lt;td&gt;9057&lt;/td&gt;        &lt;td&gt;4404&lt;/td&gt;        &lt;td&gt;4349&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;20000&lt;/td&gt;        &lt;td&gt;9206&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;11646&lt;/td&gt;        &lt;td&gt;5903&lt;/td&gt;        &lt;td&gt;5774&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;25000&lt;/td&gt;        &lt;td&gt;11205&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;7328&lt;/td&gt;        &lt;td&gt;7283&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;30000&lt;/td&gt;        &lt;td&gt;13235&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;8861&lt;/td&gt;        &lt;td&gt;8756&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;35000&lt;/td&gt;        &lt;td&gt;15546&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;10314&lt;/td&gt;        &lt;td&gt;10131&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;40000&lt;/td&gt;        &lt;td&gt;17929&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;11677&lt;/td&gt;        &lt;td&gt;11589&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_329F574D.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_673FB388.png" width="542" height="359" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;We get the expected result – the CPU clock difference between the other WP8 phones (920 and 820) clearly means slower startup and computational times. In fact, if we compensate for the CPU clock, the numbers are pretty much exactly the same. The 620 has no problem beating second generation Windows Phone 7 devices (such as the Lumia 800). The 800 has a single-core and outdated CPU, but runs at a 40% higher speed of 1.4 GHz. If we compare the 620 to the first generation WP7 devices, such as the LG Optimus 7, we get almost 100% performance gain. Moore’s Law in action here…&lt;/p&gt;  &lt;h2&gt;GPU Performance&lt;/h2&gt;  &lt;p&gt;To measure the raw CPU performance, once again I used the “Fill Rate Test Sample” from the MSDN article &lt;a href="http://msdn.microsoft.com/en-us/library/ff967560(v=VS.92).aspx"&gt;Performance Considerations in Applications for Windows Phone&lt;/a&gt;. This test turned out some surprising results!&lt;/p&gt;  &lt;p&gt;Here are the numbers in table and chart format:&lt;/p&gt;  &lt;table cellspacing="0" cellpadding="0"&gt;     &lt;tr&gt;       &lt;td&gt;&lt;strong&gt;Rectangles&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Fill Rate&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Lumia 620 FPS&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Lumia 800 FPS&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Optimus 7 FPS&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Lumia 920 FPS&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Lumia 820&lt;/strong&gt; FPS&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;0&lt;/td&gt;        &lt;td&gt;0&lt;/td&gt;        &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;50&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;1&lt;/td&gt;        &lt;td&gt;1.03&lt;/td&gt;        &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;50&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;5&lt;/td&gt;        &lt;td&gt;1.53&lt;/td&gt;        &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;50&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;10&lt;/td&gt;        &lt;td&gt;2.15&lt;/td&gt;        &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;50&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;15&lt;/td&gt;        &lt;td&gt;2.78&lt;/td&gt;        &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;48&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;20&lt;/td&gt;        &lt;td&gt;3.47&lt;/td&gt;        &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;38&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;25&lt;/td&gt;        &lt;td&gt;4.02&lt;/td&gt;        &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;34&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;30&lt;/td&gt;        &lt;td&gt;4.65&lt;/td&gt;        &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;30&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;35&lt;/td&gt;        &lt;td&gt;5.28&lt;/td&gt;        &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;26&lt;/td&gt;        &lt;td&gt;55&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;40&lt;/td&gt;        &lt;td&gt;5.9&lt;/td&gt;        &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;23&lt;/td&gt;        &lt;td&gt;50&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;45&lt;/td&gt;        &lt;td&gt;6.53&lt;/td&gt;        &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;21&lt;/td&gt;        &lt;td&gt;45&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;50&lt;/td&gt;        &lt;td&gt;7.15&lt;/td&gt;        &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;19&lt;/td&gt;        &lt;td&gt;42&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;55&lt;/td&gt;        &lt;td&gt;7.78&lt;/td&gt;        &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;53&lt;/td&gt;        &lt;td&gt;17&lt;/td&gt;        &lt;td&gt;40&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;8.4&lt;/td&gt;        &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;49&lt;/td&gt;        &lt;td&gt;16&lt;/td&gt;        &lt;td&gt;36&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;65&lt;/td&gt;        &lt;td&gt;0.03&lt;/td&gt;        &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;45&lt;/td&gt;        &lt;td&gt;15&lt;/td&gt;        &lt;td&gt;33&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;70&lt;/td&gt;        &lt;td&gt;9.65&lt;/td&gt;        &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;43&lt;/td&gt;        &lt;td&gt;14&lt;/td&gt;        &lt;td&gt;31&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;75&lt;/td&gt;        &lt;td&gt;10.28&lt;/td&gt;        &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;42&lt;/td&gt;        &lt;td&gt;14&lt;/td&gt;        &lt;td&gt;30&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;80&lt;/td&gt;        &lt;td&gt;10.9&lt;/td&gt;        &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;40&lt;/td&gt;        &lt;td&gt;13&lt;/td&gt;        &lt;td&gt;29&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;85&lt;/td&gt;        &lt;td&gt;11.53&lt;/td&gt;        &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;37&lt;/td&gt;        &lt;td&gt;12&lt;/td&gt;        &lt;td&gt;26&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;90&lt;/td&gt;        &lt;td&gt;12.15&lt;/td&gt;        &lt;td&gt;58&lt;/td&gt;        &lt;td&gt;34&lt;/td&gt;        &lt;td&gt;11&lt;/td&gt;        &lt;td&gt;25&lt;/td&gt;        &lt;td&gt;57&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;95&lt;/td&gt;        &lt;td&gt;12.775&lt;/td&gt;        &lt;td&gt;53&lt;/td&gt;        &lt;td&gt;33&lt;/td&gt;        &lt;td&gt;11&lt;/td&gt;        &lt;td&gt;24&lt;/td&gt;        &lt;td&gt;54&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;100&lt;/td&gt;        &lt;td&gt;13.4&lt;/td&gt;        &lt;td&gt;49&lt;/td&gt;        &lt;td&gt;32&lt;/td&gt;        &lt;td&gt;10&lt;/td&gt;        &lt;td&gt;23&lt;/td&gt;        &lt;td&gt;51&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;105&lt;/td&gt;        &lt;td&gt;14.03&lt;/td&gt;        &lt;td&gt;45&lt;/td&gt;        &lt;td&gt;30&lt;/td&gt;        &lt;td&gt;10&lt;/td&gt;        &lt;td&gt;22&lt;/td&gt;        &lt;td&gt;48&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;110&lt;/td&gt;        &lt;td&gt;14.65&lt;/td&gt;        &lt;td&gt;44&lt;/td&gt;        &lt;td&gt;30&lt;/td&gt;        &lt;td&gt;9&lt;/td&gt;        &lt;td&gt;21&lt;/td&gt;        &lt;td&gt;47&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;120&lt;/td&gt;        &lt;td&gt;15.9&lt;/td&gt;        &lt;td&gt;40&lt;/td&gt;        &lt;td&gt;27&lt;/td&gt;        &lt;td&gt;9&lt;/td&gt;        &lt;td&gt;20&lt;/td&gt;        &lt;td&gt;44&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;130&lt;/td&gt;        &lt;td&gt;17.15&lt;/td&gt;        &lt;td&gt;40&lt;/td&gt;        &lt;td&gt;26&lt;/td&gt;        &lt;td&gt;8&lt;/td&gt;        &lt;td&gt;18&lt;/td&gt;        &lt;td&gt;41&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;140&lt;/td&gt;        &lt;td&gt;18.4&lt;/td&gt;        &lt;td&gt;40&lt;/td&gt;        &lt;td&gt;24&lt;/td&gt;        &lt;td&gt;7&lt;/td&gt;        &lt;td&gt;17&lt;/td&gt;        &lt;td&gt;39&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;150&lt;/td&gt;        &lt;td&gt;19.65&lt;/td&gt;        &lt;td&gt;36&lt;/td&gt;        &lt;td&gt;23&lt;/td&gt;        &lt;td&gt;7&lt;/td&gt;        &lt;td&gt;16&lt;/td&gt;        &lt;td&gt;36&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;170&lt;/td&gt;        &lt;td&gt;22.15&lt;/td&gt;        &lt;td&gt;33&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;200&lt;/td&gt;        &lt;td&gt;25.78&lt;/td&gt;        &lt;td&gt;29&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_1218179B.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_66D38093.png" width="485" height="293" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Barring some measurement inaccuracies, the 620 performed just as good as our current champion, the 820 – even though the SoC runs at 66% speed! I’ve tried to find a reason for this difference, but I couldn’t find a definite answer. It seems like the bottleneck is elsewhere – perhaps the memory bandwidth, the graphics driver or some other architectural component. If you have an idea of why the 620 performs this much better than expected, please share it in the comments.&lt;/p&gt;  &lt;p&gt;Nevertheless, it seems like developers we won’t have to worry about Fill Rates with the 620. It keeps an impressive 60 fps up until the Fill Rate of 12, which should be more than enough for any application. Even at a Fill Rate of 24, the frame rate is still above the red zone of 30. &lt;/p&gt;  &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;From a developer’s point of view, the 620 is noticeably slower than the other WP8 devices when it comes to raw computing power. However, this speed difference shouldn’t cause much problems if you are sticking with the performance guidelines outlined in the previous parts of this series. Even better, when it comes to Fill Rate, you have nothing to worry about. For Fill Rate optimization, you should still use the Lumia 920. If you are also targeting WP7 devices, the Lumia 610 should be your baseline. The first generation phones are finally becoming rare enough to ignore minor FPS problems on. Which is good news, since it’s often extremely hard to keep the Fill Rate above their FPS drop point of 2.5.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=11142" width="1" height="1"&gt;</content><author><name>vbandi</name><uri>http://dotneteers.net/members/vbandi/default.aspx</uri></author><category term="Windows Phone 7" scheme="http://dotneteers.net/blogs/vbandi/archive/tags/Windows+Phone+7/default.aspx" /><category term="WP Performance" scheme="http://dotneteers.net/blogs/vbandi/archive/tags/WP+Performance/default.aspx" /></entry><entry><title>DataContextChanged event for WinRT</title><link rel="alternate" type="text/html" href="/blogs/vbandi/archive/2013/01/23/datacontextchanged-event-for-winrt.aspx" /><id>/blogs/vbandi/archive/2013/01/23/datacontextchanged-event-for-winrt.aspx</id><published>2013-01-23T10:22:41Z</published><updated>2013-01-23T10:22:41Z</updated><content type="html">&lt;p&gt;Unlike WPF, WinRT (or Windows Store App API) does not have a DataContextChanged event handler. This may cause problems if you are doing framework-y stuff, or even for some controls, where you are . &lt;/p&gt;  &lt;p&gt;Luckily, &lt;a href="http://csharperimage.jeremylikness.com/2009/07/silverlight-datacontext-changed-event.html" target="_blank"&gt;Jeremy Likness wrote a solution&lt;/a&gt; for the exact same problem for Silverlight, back in 2009. Silverlight now has the DataContextChanged event implemented, but his technique is still useful for WinRT. There is a small change to do though: the way you perform callback from an attached property is a tiny bit different. &lt;/p&gt;  &lt;p&gt;So, here is the complete code that compiles and works perfectly on WinRT. Again, all credit goes to &lt;a href="http://csharperimage.jeremylikness.com/" target="_blank"&gt;Jeremy&lt;/a&gt; for this solution!&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; DataContextChangedHelper&amp;lt;T&amp;gt; &lt;span class="kwrd"&gt;where&lt;/span&gt; T : FrameworkElement, IDataContextChangedHandler&amp;lt;T&amp;gt;
{
    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; INTERNAL_CONTEXT = &lt;span class="str"&gt;&amp;quot;InternalDataContext&amp;quot;&lt;/span&gt;;

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty InternalDataContextProperty =
        DependencyProperty.Register(INTERNAL_CONTEXT,
                                    &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Object),
                                    &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(T),
                                    &lt;span class="kwrd"&gt;new&lt;/span&gt; PropertyMetadata(&lt;span class="kwrd"&gt;null&lt;/span&gt;, _DataContextChanged));

    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; _DataContextChanged(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, DependencyPropertyChangedEventArgs e)
    {
        T control = (T)sender;
        control.DataContextChanged(control, e);
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Bind(T control)
    {
        control.SetBinding(InternalDataContextProperty, &lt;span class="kwrd"&gt;new&lt;/span&gt; Binding());
    }
}

&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; IDataContextChangedHandler&amp;lt;T&amp;gt; &lt;span class="kwrd"&gt;where&lt;/span&gt; T : FrameworkElement
{
    &lt;span class="kwrd"&gt;void&lt;/span&gt; DataContextChanged(T sender, DependencyPropertyChangedEventArgs e);
}&lt;/pre&gt;

&lt;p&gt;&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;To actually have the DataContextChanged event fire for your control (FrameworkElement), you have to add one more line in your control’s constructor:&lt;/p&gt;

&lt;p&gt;DataContextChangedHelper&amp;lt;MyControl&amp;gt;.Bind(this); &lt;/p&gt;

&lt;p&gt;That’s it!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=6511" width="1" height="1"&gt;</content><author><name>vbandi</name><uri>http://dotneteers.net/members/vbandi/default.aspx</uri></author></entry><entry><title>Windows Phone Performance – Part 7 of many: Lumia 820 performance</title><link rel="alternate" type="text/html" href="/blogs/vbandi/archive/2013/01/10/windows-phone-performance-part-7-of-many-lumia-820-performance.aspx" /><id>/blogs/vbandi/archive/2013/01/10/windows-phone-performance-part-7-of-many-lumia-820-performance.aspx</id><published>2013-01-10T11:17:54Z</published><updated>2013-01-10T11:17:54Z</updated><content type="html">&lt;p&gt;&lt;em&gt;In this post, I’ll take a look at the performance of the Nokia Lumia 820 from a developer’s point of view. &lt;/em&gt;&lt;em&gt;This post is part of my &lt;a href="http://dotneteers.net/blogs/vbandi/archive/tags/WP+Performance/default.aspx"&gt;Windows Phone performance series&lt;/a&gt;. &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;HUGE thanks to &lt;a href="http://sorokoletov.com/" target="_blank"&gt;Alex Sorokoletov&lt;/a&gt; for performing the tests in this article. Since I didn’t have access to a Lumia 820, without him, this post would not have been possible.&lt;/em&gt;&lt;/p&gt;  &lt;h2&gt;The Nokia Lumia 820&lt;/h2&gt;  &lt;p&gt;The little brother of the flagship Nokia Lumia 920, the 820 has nothing to be ashamed of when it comes to performance. Actually, the 820 has the same dual-core Snapdragon S4 processor as the 920, running at the same 1.5GHz speed. From a developer’s perspective, the big difference is the screen – while the 920 has 1280x768 pixels, the 820 keeps the modest 800x480 pixel resolution of Windows Phone 7. Most of the differences between the 920 and the 820 have to do with how the 920 has to work with 2.5 as much pixels as the 820. &lt;/p&gt;  &lt;p&gt;It is worth noting that the&lt;strike&gt; 820 only has&lt;/strike&gt; minimum requirement for 800x480 Windows Phone devices is 512MByte RAM, while the 920 has twice as much. This also boils down to the difference in screen pixels – apps on the the 920 need more RAM simply to decode the high resolution bitmaps and keep them in memory.     &lt;br /&gt;&lt;strong&gt;Update: t&lt;/strong&gt;he Lumia 820 has 1G RAM&lt;/p&gt;  &lt;p&gt;Let’s see how the 820 performs in our little tests!&lt;/p&gt;  &lt;h2&gt;Application Loading / CPU performance&lt;/h2&gt;  &lt;p&gt;For this one, I am using the old artificial test from the second part of this series (&lt;a href="http://vbandi.dotneteers.net/blogs/vbandi/archive/2012/02/18/windows-phone-performance-part-2-of-many-it-s-full-of-stars.aspx"&gt;It’s Full of Stars!&lt;/a&gt;). &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;table cellspacing="0" cellpadding="0"&gt;     &lt;tr&gt;       &lt;td&gt;&lt;strong&gt;Number of Stars&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Lumia 610&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Optimus 7&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Lumia 800&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Lumia 920&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Lumia 820&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;100&lt;/td&gt;        &lt;td&gt;624&lt;/td&gt;        &lt;td&gt;399&lt;/td&gt;        &lt;td&gt;347&lt;/td&gt;        &lt;td&gt;164&lt;/td&gt;        &lt;td&gt;497&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;1000&lt;/td&gt;        &lt;td&gt;1325&lt;/td&gt;        &lt;td&gt;1133&lt;/td&gt;        &lt;td&gt;846&lt;/td&gt;        &lt;td&gt;449&lt;/td&gt;        &lt;td&gt;539&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;2000&lt;/td&gt;        &lt;td&gt;2106&lt;/td&gt;        &lt;td&gt;1882&lt;/td&gt;        &lt;td&gt;1357&lt;/td&gt;        &lt;td&gt;711&lt;/td&gt;        &lt;td&gt;723&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;5000&lt;/td&gt;        &lt;td&gt;4303&lt;/td&gt;        &lt;td&gt;4258&lt;/td&gt;        &lt;td&gt;3007&lt;/td&gt;        &lt;td&gt;1557&lt;/td&gt;        &lt;td&gt;1465&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;10000&lt;/td&gt;        &lt;td&gt;8430&lt;/td&gt;        &lt;td&gt;8348&lt;/td&gt;        &lt;td&gt;5792&lt;/td&gt;        &lt;td&gt;2913&lt;/td&gt;        &lt;td&gt;2899&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;15000&lt;/td&gt;        &lt;td&gt;12401&lt;/td&gt;        &lt;td&gt;12183&lt;/td&gt;        &lt;td&gt;9057&lt;/td&gt;        &lt;td&gt;4404&lt;/td&gt;        &lt;td&gt;4349&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;20000&lt;/td&gt;        &lt;td&gt;17205&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;11646&lt;/td&gt;        &lt;td&gt;5903&lt;/td&gt;        &lt;td&gt;5774&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;25000&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;7328&lt;/td&gt;        &lt;td&gt;7283&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;30000&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;8861&lt;/td&gt;        &lt;td&gt;8756&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;35000&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;10314&lt;/td&gt;        &lt;td&gt;10131&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;40000&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;11677&lt;/td&gt;        &lt;td&gt;11589&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_2C2565E7.png"&gt;&lt;img title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_4BD43FAF.png" width="542" height="359" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;With Compile in the Cloud being a general Windows Phone 8 feature, the 820 should start applications just as fast as the 920. The first two launches show a bit different picture though, the reasons of which is not entirely clear. Alex performed multiple measurements for each pass, but the 100 star test consistently returned a slower startup time. Regardless of this difference, you can see that the 820 performed roughly as well as the 920 did (almost completely hiding the 920’s line in the chart), even though the later one had to render much more physical pixels.&lt;/p&gt;  &lt;h2&gt;GPU Performance&lt;/h2&gt;  &lt;p&gt;To measure the raw CPU performance, once again I used the “Fill Rate Test Sample” from the MSDN article &lt;a href="http://msdn.microsoft.com/en-us/library/ff967560(v=VS.92).aspx"&gt;Performance Considerations in Applications for Windows Phone&lt;/a&gt;. Here are the numbers in table and chart format:&lt;/p&gt;  &lt;table cellspacing="0" cellpadding="0"&gt;     &lt;tr&gt;       &lt;td&gt;Rectangles&lt;/td&gt;        &lt;td&gt;Fill Rate&lt;/td&gt;        &lt;td&gt;Lumia 610 FPS&lt;/td&gt;        &lt;td&gt;Lumia 800 FPS&lt;/td&gt;        &lt;td&gt;Optimus 7 FPS&lt;/td&gt;        &lt;td&gt;Lumia 920 FPS&lt;/td&gt;        &lt;td&gt;Lumia 820 FPS&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;0&lt;/td&gt;        &lt;td&gt;0.9&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;50&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;1&lt;/td&gt;        &lt;td&gt;1.05&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;50&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;5&lt;/td&gt;        &lt;td&gt;1.56&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;50&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;10&lt;/td&gt;        &lt;td&gt;2.19&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;50&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;15&lt;/td&gt;        &lt;td&gt;2.83&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;48&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;20&lt;/td&gt;        &lt;td&gt;3.47&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;38&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;25&lt;/td&gt;        &lt;td&gt;4.1&lt;/td&gt;        &lt;td&gt;54&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;34&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;30&lt;/td&gt;        &lt;td&gt;4.74&lt;/td&gt;        &lt;td&gt;48&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;30&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;35&lt;/td&gt;        &lt;td&gt;5.37&lt;/td&gt;        &lt;td&gt;45&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;26&lt;/td&gt;        &lt;td&gt;55&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;40&lt;/td&gt;        &lt;td&gt;6.01&lt;/td&gt;        &lt;td&gt;41&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;23&lt;/td&gt;        &lt;td&gt;50&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;45&lt;/td&gt;        &lt;td&gt;6.65&lt;/td&gt;        &lt;td&gt;38&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;21&lt;/td&gt;        &lt;td&gt;45&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;50&lt;/td&gt;        &lt;td&gt;7.28&lt;/td&gt;        &lt;td&gt;35&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;19&lt;/td&gt;        &lt;td&gt;42&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;55&lt;/td&gt;        &lt;td&gt;7.92&lt;/td&gt;        &lt;td&gt;32&lt;/td&gt;        &lt;td&gt;53&lt;/td&gt;        &lt;td&gt;17&lt;/td&gt;        &lt;td&gt;40&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;8.56&lt;/td&gt;        &lt;td&gt;29&lt;/td&gt;        &lt;td&gt;49&lt;/td&gt;        &lt;td&gt;16&lt;/td&gt;        &lt;td&gt;36&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;65&lt;/td&gt;        &lt;td&gt;9.19&lt;/td&gt;        &lt;td&gt;28&lt;/td&gt;        &lt;td&gt;45&lt;/td&gt;        &lt;td&gt;15&lt;/td&gt;        &lt;td&gt;33&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;70&lt;/td&gt;        &lt;td&gt;9.83&lt;/td&gt;        &lt;td&gt;27&lt;/td&gt;        &lt;td&gt;43&lt;/td&gt;        &lt;td&gt;14&lt;/td&gt;        &lt;td&gt;31&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;75&lt;/td&gt;        &lt;td&gt;10.46&lt;/td&gt;        &lt;td&gt;25&lt;/td&gt;        &lt;td&gt;42&lt;/td&gt;        &lt;td&gt;14&lt;/td&gt;        &lt;td&gt;30&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;80&lt;/td&gt;        &lt;td&gt;11.1&lt;/td&gt;        &lt;td&gt;24&lt;/td&gt;        &lt;td&gt;40&lt;/td&gt;        &lt;td&gt;13&lt;/td&gt;        &lt;td&gt;29&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;85&lt;/td&gt;        &lt;td&gt;11.74&lt;/td&gt;        &lt;td&gt;22&lt;/td&gt;        &lt;td&gt;37&lt;/td&gt;        &lt;td&gt;12&lt;/td&gt;        &lt;td&gt;26&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;90&lt;/td&gt;        &lt;td&gt;12.37&lt;/td&gt;        &lt;td&gt;21&lt;/td&gt;        &lt;td&gt;34&lt;/td&gt;        &lt;td&gt;11&lt;/td&gt;        &lt;td&gt;25&lt;/td&gt;        &lt;td&gt;57&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;95&lt;/td&gt;        &lt;td&gt;13&lt;/td&gt;        &lt;td&gt;20&lt;/td&gt;        &lt;td&gt;33&lt;/td&gt;        &lt;td&gt;11&lt;/td&gt;        &lt;td&gt;24&lt;/td&gt;        &lt;td&gt;54&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;100&lt;/td&gt;        &lt;td&gt;13.6&lt;/td&gt;        &lt;td&gt;19&lt;/td&gt;        &lt;td&gt;32&lt;/td&gt;        &lt;td&gt;10&lt;/td&gt;        &lt;td&gt;23&lt;/td&gt;        &lt;td&gt;51&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;105&lt;/td&gt;        &lt;td&gt;14.28&lt;/td&gt;        &lt;td&gt;18&lt;/td&gt;        &lt;td&gt;30&lt;/td&gt;        &lt;td&gt;10&lt;/td&gt;        &lt;td&gt;22&lt;/td&gt;        &lt;td&gt;48&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;110&lt;/td&gt;        &lt;td&gt;14.92&lt;/td&gt;        &lt;td&gt;17&lt;/td&gt;        &lt;td&gt;30&lt;/td&gt;        &lt;td&gt;9&lt;/td&gt;        &lt;td&gt;21&lt;/td&gt;        &lt;td&gt;47&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;120&lt;/td&gt;        &lt;td&gt;16.19&lt;/td&gt;        &lt;td&gt;16&lt;/td&gt;        &lt;td&gt;27&lt;/td&gt;        &lt;td&gt;9&lt;/td&gt;        &lt;td&gt;20&lt;/td&gt;        &lt;td&gt;44&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;130&lt;/td&gt;        &lt;td&gt;17.46&lt;/td&gt;        &lt;td&gt;15&lt;/td&gt;        &lt;td&gt;26&lt;/td&gt;        &lt;td&gt;8&lt;/td&gt;        &lt;td&gt;18&lt;/td&gt;        &lt;td&gt;41&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;140&lt;/td&gt;        &lt;td&gt;18.73&lt;/td&gt;        &lt;td&gt;14&lt;/td&gt;        &lt;td&gt;24&lt;/td&gt;        &lt;td&gt;7&lt;/td&gt;        &lt;td&gt;17&lt;/td&gt;        &lt;td&gt;39&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;150&lt;/td&gt;        &lt;td&gt;20&lt;/td&gt;        &lt;td&gt;13&lt;/td&gt;        &lt;td&gt;23&lt;/td&gt;        &lt;td&gt;7&lt;/td&gt;        &lt;td&gt;16&lt;/td&gt;        &lt;td&gt;36&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_76ACA3C1.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_4B680CBA.png" width="485" height="293" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The Lumia 820 is clearly the top performer here – no wonder, since it has much less pixels to work with than the 920. The 820 keeps a solid 60 FPS up until a Fill Rate of 12, and still doesn’t drop below an acceptable 30 with a Fill Rate of 150. This really shows how the Snapdragon S4’s GPU may even be a bit too powerful for the phone (at least when it comes to Silverlight applications). It can compose 2.5 – 3 times as many full-screen layers as on the 920 before the first signs of lags even show. Not surprisingly, this is the same multiplier as the number of pixels there are between the two phones. Fill Rate is about number of pixels after all.&lt;/p&gt;  &lt;h2&gt;&lt;/h2&gt;  &lt;p&gt;&lt;/p&gt;  &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;In CPU, the two Windows Phone 8 Lumia phones perform similarly. However, when it comes to the GPU, the 820 feels like a race car engine in a common vehicle. &lt;/p&gt;  &lt;p&gt;When developing Windows Phone 8 applications and testing on the Lumia 820, you have to keep in mind that high-resolution phones do not tolerate Fill Rates above 4.5 or so. Even though your applications may keep a consistently smooth animation at a Fill Rate of 6 on the 820, other WP phones will struggle. So, keep your &lt;a href="http://dotneteers.net/blogs/vbandi/archive/2012/03/14/windows-phone-performance-part-3-of-many-tie-fighters-and-drunk-spaceship-captains.aspx" target="_blank"&gt;Frame Rate Counters&lt;/a&gt; turned on. Fortunately, it is not hard to keep the Fill Rate below 5 – we are in a much better situation than what we had with the first generation Windows Phones, where the a value of 2.5 already caused problems, and a lot of time went into making sure we kept the Fill Rate below that level.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=6500" width="1" height="1"&gt;</content><author><name>vbandi</name><uri>http://dotneteers.net/members/vbandi/default.aspx</uri></author><category term="WP Performance" scheme="http://dotneteers.net/blogs/vbandi/archive/tags/WP+Performance/default.aspx" /></entry><entry><title>Windows Phone performance – Part 6 of many: Nokia Lumia 920 performance</title><link rel="alternate" type="text/html" href="/blogs/vbandi/archive/2012/12/27/windows-phone-performance-part-6-of-many-nokia-lumia-920-performance.aspx" /><id>/blogs/vbandi/archive/2012/12/27/windows-phone-performance-part-6-of-many-nokia-lumia-920-performance.aspx</id><published>2012-12-27T12:37:17Z</published><updated>2012-12-27T12:37:17Z</updated><content type="html">&lt;p&gt;&lt;em&gt;In this post, I’ll take a look at the performance of the Nokia Lumia 920 from a developer’s point of view. &lt;/em&gt;&lt;em&gt;This post is part of my &lt;a href="http://dotneteers.net/blogs/vbandi/archive/tags/WP+Performance/default.aspx" target="_blank"&gt;Windows Phone performance series&lt;/a&gt;. &lt;/em&gt;&lt;/p&gt;  &lt;h2&gt;&lt;em&gt;&lt;/em&gt;&lt;/h2&gt;  &lt;h1&gt;The Nokia Lumia 920&lt;/h1&gt;  &lt;p&gt;As Nokia’s flagship Windows Phone device, the Lumia 920 is a beast. Both in size and performance, the phone is great. In fact, the very first thing I noticed as a Windows Phone 7 user (apart from the new Start Screen) was how quickly the applications launched and how well they performed. &lt;/p&gt;  &lt;p&gt;The 920 has a screen resolution of 1280x768 (983,040 pixels). This is more than 2.5 times as many as the standard resolution of the Windows Phone 7 devices – 800x480 (384,000 pixels). Other Windows Phone 8 devices can have a resolution of 1280x720 (almost the same as the 920, but a different aspect ratio) or 800x480. The additional pixel count requires a faster CPU to render the textures and a faster GPU to move the textures around. Fortunately, both of these are taken care of with the dual-core 1.5GHz Snapdragon S4 SOC. Also, since images in your application should contain a bigger number of pixels to remain sharp, the screen pixels mean that more memory is used by the applications. Because of this, you won’t see an 1280p WIndows Phone 8 device with less than 1G RAM. &lt;/p&gt;  &lt;p&gt;In the &lt;a href="http://dotneteers.net/blogs/vbandi/archive/2012/05/31/windows-phone-performance-part-5-of-many-a-developer-s-look-at-the-nokia-lumia-610.aspx" target="_blank"&gt;previous post of this series&lt;/a&gt;, I compared the LG Optimus 7 (a first generation WP7 device), the Nokia Lumia 800 (a second generation WP7 device) and the Lumia 610 (a low-end second generation phone). Let’s add the 920 to the mix, and see how it fares!&lt;/p&gt;  &lt;h1&gt;&lt;/h1&gt;  &lt;h2&gt;Application Loading / CPU performance&lt;/h2&gt;  &lt;p&gt;With Windows Phone 7, application load times were the result of two factors – the Just-In-Time Compilation of the dlls, and the calculations needed to display the first screen of your app. With the apps growing bigger as more and bigger dlls were included in the XAP, whatever you did, a lot of them had to be JIT-ted just to get the first line of your actual code executed.&lt;/p&gt;  &lt;p&gt;Things have dramatically changed with Windows Phone 8. Thanks to the faster, dual-core processor, but most importantly, to the cloud compilation infrastructure, Silverlight apps can now start up almost as fast as the first party native apps. Cloud Compilation happens when you deploy your app into the Store, and makes 99% of the work of the Just-in-time Compiler unnecessary. With Windows Phone 7, application load times were mostly the result of the apps growing bigger as more and bigger dlls were included in the XAP. Whatever you did, a lot of them had to be JIT-ted just to get the first screen up. You can learn more details about the Cloud Compilation in the Build talk “&lt;a href="http://channel9.msdn.com/Events/Build/2012/3-005"&gt;Deep Dive into the Kernel of .NET on Windows Phone 8&lt;/a&gt;”.&lt;/p&gt;  &lt;div id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:97f00f45-f5d2-4c15-9404-31a62084b7bb" class="wlWriterEditableSmartContent" style="float:none;padding-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;display:inline;padding-right:0px;"&gt;&lt;div&gt;&lt;object width="425" height="355"&gt;&lt;param name="movie" value="http://www.youtube.com/v/c6LsB3XSsVs&amp;amp;hl=en"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/c6LsB3XSsVs&amp;amp;hl=en" type="application/x-shockwave-flash" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;&lt;/div&gt;  &lt;p&gt;&lt;em&gt;The magic of Compile in the Cloud – rowi startup time vs the People Hub.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;With the JIT compilation out of the way, let’s see how the phone deals with a lot of calculations at startup. For this, I will summon my old artificial test from the second part of this series (&lt;a href="http://vbandi.dotneteers.net/blogs/vbandi/archive/2012/02/18/windows-phone-performance-part-2-of-many-it-s-full-of-stars.aspx" target="_blank"&gt;It’s Full of Stars!&lt;/a&gt;). Please click on the link to refresh your memory, I’ll wait here.&lt;/p&gt;  &lt;p&gt;Let’s look at the numbers. The first column of the table shows how many stars (small ellipses) are drawn, and the other columns show the number of milliseconds it took to launch the application. The stars are drawn on the UI thread at startup, so this drawing delays the startup time of the app.&lt;/p&gt;  &lt;table cellspacing="0" cellpadding="0"&gt;     &lt;tr&gt;       &lt;td&gt;&lt;strong&gt;Number of Stars&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Lumia 610&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Optimus 7&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Lumia 800&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Lumia 920&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;100&lt;/td&gt;        &lt;td&gt;624&lt;/td&gt;        &lt;td&gt;399&lt;/td&gt;        &lt;td&gt;347&lt;/td&gt;        &lt;td&gt;164&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;1000&lt;/td&gt;        &lt;td&gt;1325&lt;/td&gt;        &lt;td&gt;1133&lt;/td&gt;        &lt;td&gt;846&lt;/td&gt;        &lt;td&gt;449&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;2000&lt;/td&gt;        &lt;td&gt;2106&lt;/td&gt;        &lt;td&gt;1882&lt;/td&gt;        &lt;td&gt;1357&lt;/td&gt;        &lt;td&gt;711&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;5000&lt;/td&gt;        &lt;td&gt;4303&lt;/td&gt;        &lt;td&gt;4258&lt;/td&gt;        &lt;td&gt;3007&lt;/td&gt;        &lt;td&gt;1557&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;10000&lt;/td&gt;        &lt;td&gt;8430&lt;/td&gt;        &lt;td&gt;8348&lt;/td&gt;        &lt;td&gt;5792&lt;/td&gt;        &lt;td&gt;2913&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;15000&lt;/td&gt;        &lt;td&gt;12401&lt;/td&gt;        &lt;td&gt;12183&lt;/td&gt;        &lt;td&gt;9057&lt;/td&gt;        &lt;td&gt;4404&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;20000&lt;/td&gt;        &lt;td&gt;17205&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;11646&lt;/td&gt;        &lt;td&gt;5903&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;25000&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;7328&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;30000&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;8861&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;35000&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;10314&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;40000&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;&amp;#160;&lt;/td&gt;        &lt;td&gt;11677&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Here is it in a chart form:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_631787B2.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_02C6617B.png" width="542" height="359" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;As you can see, the 920 kicks the rear end of every WP7 phone – even the fastest Lumia 800 is beat by a factor of 2, despite the much larger number of pixels to deal with. Not bad! &lt;/p&gt;  &lt;p&gt;You will also experience this difference when navigating between pages of the application. The layout and render cycle is much faster, resulting in a better navigation experience. &lt;/p&gt;  &lt;h2&gt;GPU Performance&lt;/h2&gt;  &lt;p&gt;To measure the raw CPU performance, I used the “Fill Rate Test Sample” from the MSDN article &lt;a href="http://msdn.microsoft.com/en-us/library/ff967560(v=VS.92).aspx"&gt;Performance Considerations in Applications for Windows Phone&lt;/a&gt;. This does not test things like shaders, perspective transformations, etc – but it is a good first indicator. I gradually increased the number of rectangles on the screen, which in turn increased the fill rate. As we saw in part 4 of this series, &lt;a href="http://www.dotneteers.net/blogs/vbandi/archive/2012/03/22/windows-phone-performance-part-4-of-many-the-power-of-the-gpu.aspx"&gt;The Power of the GPU&lt;/a&gt;, Fill Rate is an important measurement for how much work the GPU has to do, and a high Fill Rate makes the FPS (frame per seconds) drop. Without further ado, here are the results in table and chart format:&lt;/p&gt;  &lt;table cellspacing="0" cellpadding="0"&gt;     &lt;tr&gt;       &lt;td&gt;&lt;strong&gt;Rectangles&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Fill Rate&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Lumia 610 FPS&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Lumia 800 FPS&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Optimus 7 FPS&lt;/strong&gt;&lt;/td&gt;        &lt;td&gt;&lt;strong&gt;Lumia 920 FPS&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;0&lt;/td&gt;        &lt;td&gt;0.9&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;50&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;1&lt;/td&gt;        &lt;td&gt;1.05&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;50&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;5&lt;/td&gt;        &lt;td&gt;1.56&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;50&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;10&lt;/td&gt;        &lt;td&gt;2.19&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;50&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;15&lt;/td&gt;        &lt;td&gt;2.83&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;48&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;20&lt;/td&gt;        &lt;td&gt;3.47&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;38&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;25&lt;/td&gt;        &lt;td&gt;4.1&lt;/td&gt;        &lt;td&gt;54&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;34&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;30&lt;/td&gt;        &lt;td&gt;4.74&lt;/td&gt;        &lt;td&gt;48&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;30&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;35&lt;/td&gt;        &lt;td&gt;5.37&lt;/td&gt;        &lt;td&gt;45&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;26&lt;/td&gt;        &lt;td&gt;55&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;40&lt;/td&gt;        &lt;td&gt;6.01&lt;/td&gt;        &lt;td&gt;41&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;23&lt;/td&gt;        &lt;td&gt;50&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;45&lt;/td&gt;        &lt;td&gt;6.65&lt;/td&gt;        &lt;td&gt;38&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;21&lt;/td&gt;        &lt;td&gt;45&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;50&lt;/td&gt;        &lt;td&gt;7.28&lt;/td&gt;        &lt;td&gt;35&lt;/td&gt;        &lt;td&gt;59&lt;/td&gt;        &lt;td&gt;19&lt;/td&gt;        &lt;td&gt;42&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;55&lt;/td&gt;        &lt;td&gt;7.92&lt;/td&gt;        &lt;td&gt;32&lt;/td&gt;        &lt;td&gt;53&lt;/td&gt;        &lt;td&gt;17&lt;/td&gt;        &lt;td&gt;40&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;60&lt;/td&gt;        &lt;td&gt;8.56&lt;/td&gt;        &lt;td&gt;29&lt;/td&gt;        &lt;td&gt;49&lt;/td&gt;        &lt;td&gt;16&lt;/td&gt;        &lt;td&gt;36&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;65&lt;/td&gt;        &lt;td&gt;9.19&lt;/td&gt;        &lt;td&gt;28&lt;/td&gt;        &lt;td&gt;45&lt;/td&gt;        &lt;td&gt;15&lt;/td&gt;        &lt;td&gt;33&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;70&lt;/td&gt;        &lt;td&gt;9.83&lt;/td&gt;        &lt;td&gt;27&lt;/td&gt;        &lt;td&gt;43&lt;/td&gt;        &lt;td&gt;14&lt;/td&gt;        &lt;td&gt;31&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;75&lt;/td&gt;        &lt;td&gt;10.46&lt;/td&gt;        &lt;td&gt;25&lt;/td&gt;        &lt;td&gt;42&lt;/td&gt;        &lt;td&gt;14&lt;/td&gt;        &lt;td&gt;30&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;80&lt;/td&gt;        &lt;td&gt;11.1&lt;/td&gt;        &lt;td&gt;24&lt;/td&gt;        &lt;td&gt;40&lt;/td&gt;        &lt;td&gt;13&lt;/td&gt;        &lt;td&gt;29&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;85&lt;/td&gt;        &lt;td&gt;11.74&lt;/td&gt;        &lt;td&gt;22&lt;/td&gt;        &lt;td&gt;37&lt;/td&gt;        &lt;td&gt;12&lt;/td&gt;        &lt;td&gt;26&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;90&lt;/td&gt;        &lt;td&gt;12.37&lt;/td&gt;        &lt;td&gt;21&lt;/td&gt;        &lt;td&gt;34&lt;/td&gt;        &lt;td&gt;11&lt;/td&gt;        &lt;td&gt;25&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;95&lt;/td&gt;        &lt;td&gt;13&lt;/td&gt;        &lt;td&gt;20&lt;/td&gt;        &lt;td&gt;33&lt;/td&gt;        &lt;td&gt;11&lt;/td&gt;        &lt;td&gt;24&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;100&lt;/td&gt;        &lt;td&gt;13.6&lt;/td&gt;        &lt;td&gt;19&lt;/td&gt;        &lt;td&gt;32&lt;/td&gt;        &lt;td&gt;10&lt;/td&gt;        &lt;td&gt;23&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;105&lt;/td&gt;        &lt;td&gt;14.28&lt;/td&gt;        &lt;td&gt;18&lt;/td&gt;        &lt;td&gt;30&lt;/td&gt;        &lt;td&gt;10&lt;/td&gt;        &lt;td&gt;22&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;110&lt;/td&gt;        &lt;td&gt;14.92&lt;/td&gt;        &lt;td&gt;17&lt;/td&gt;        &lt;td&gt;30&lt;/td&gt;        &lt;td&gt;9&lt;/td&gt;        &lt;td&gt;21&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;120&lt;/td&gt;        &lt;td&gt;16.19&lt;/td&gt;        &lt;td&gt;16&lt;/td&gt;        &lt;td&gt;27&lt;/td&gt;        &lt;td&gt;9&lt;/td&gt;        &lt;td&gt;20&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;130&lt;/td&gt;        &lt;td&gt;17.46&lt;/td&gt;        &lt;td&gt;15&lt;/td&gt;        &lt;td&gt;26&lt;/td&gt;        &lt;td&gt;8&lt;/td&gt;        &lt;td&gt;18&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;140&lt;/td&gt;        &lt;td&gt;18.73&lt;/td&gt;        &lt;td&gt;14&lt;/td&gt;        &lt;td&gt;24&lt;/td&gt;        &lt;td&gt;7&lt;/td&gt;        &lt;td&gt;17&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;150&lt;/td&gt;        &lt;td&gt;20&lt;/td&gt;        &lt;td&gt;13&lt;/td&gt;        &lt;td&gt;23&lt;/td&gt;        &lt;td&gt;7&lt;/td&gt;        &lt;td&gt;16&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_5B8C1845.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_1B55FECB.png" width="485" height="293" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In this test, the Lumia 800 is still better than the 920. The reason for that is the sheer number of pixels the GPU has to deal with – the 920 has 2.5 times as many pixels as the Lumia 800. On the 920, the frame rates start to drop around a fill rate of 5, while the 800 can still push pixels at 60 fps up until a fill rate of 7.5. So, what does it mean for your application? It means that as long as you have less than 5 (screen-sized) layers in your app (e.g. background picture, darkening layer, lots of text over other images, etc), you will be fine, the scrolling will not become jumpy. Frankly, it is hard to think how one would exhaust the Fill Rate of 4 in a normal Silverlight application. The low-end 610 can handle a Fill Rate of 4 easily, only the first generation devices will have problems with it.&lt;/p&gt;  &lt;h2&gt;&lt;/h2&gt;  &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;The Lumia 920 launches apps and navigates between screens much faster, and performs as smooth as we became used to with Windows Phone – despite the much higher pixel count. Overall, applications feel much more snappier, and finally performance parity between native apps and Silverlight apps can be acheved. I expect similar performance from the other HD phones, such as the HTC 8X or the Samsung Ativ. 800x480 devices may perform even better in the Fill Rate test, but I couldn’t measure it – if I get my hands on such a phone, I will write another blog post.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=6483" width="1" height="1"&gt;</content><author><name>vbandi</name><uri>http://dotneteers.net/members/vbandi/default.aspx</uri></author><category term="WP Performance" scheme="http://dotneteers.net/blogs/vbandi/archive/tags/WP+Performance/default.aspx" /></entry><entry><title>Adding and Editing WinRT Behaviors with Blend</title><link rel="alternate" type="text/html" href="/blogs/vbandi/archive/2012/09/14/adding-and-editing-winrt-behaviors-with-blend.aspx" /><id>/blogs/vbandi/archive/2012/09/14/adding-and-editing-winrt-behaviors-with-blend.aspx</id><published>2012-09-14T09:06:00Z</published><updated>2012-09-14T09:06:00Z</updated><content type="html">&lt;p&gt;I am a huuuuuuge fan of Behaviors (and Actions and Triggers) for Silverlight and WPF. I have been very disappointed when WinRT turned out not to support them.&lt;/p&gt;
&lt;p&gt;Luckily, &lt;a target="_blank" href="http://dotnetbyexample.blogspot.hu/2012/03/attached-behaviors-for-windows-8-metro.html"&gt;Joost&amp;nbsp;van Schaik created&lt;/a&gt; &lt;a target="_blank" href="http://winrtbehaviors.codeplex.com/"&gt;WinRTBehaviors&lt;/a&gt; on CodePlex (also available on &lt;a target="_blank" href="https://nuget.org/packages/WinRtBehaviors"&gt;NuGet&lt;/a&gt;). But his solution still lacks any Blend support. I have not been able to reproduce the full Blend behavior editing experience, but I managed to take the first baby-step that at least saves you from creating Behaviors from code.&lt;/p&gt;
&lt;p&gt;Here is how to use the updated WinRTBehaviors with Blend. &lt;/p&gt;
&lt;p&gt;First, let&amp;rsquo;s create a simple Behavior for illustration purposes. It can be attached to a Rectangle, and changes the Rectangle&amp;rsquo;s color when it is pressed. Told you it was simple &lt;img src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/wlEmoticon_2D00_smile_5F00_1867BC7F.png" alt="Smile" style="border-top-style:none;border-left-style:none;border-bottom-style:none;border-right-style:none;" class="wlEmoticon wlEmoticon-smile" /&gt;&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; WinRtBehaviors;
&lt;span class="kwrd"&gt;using&lt;/span&gt; Windows.UI;
&lt;span class="kwrd"&gt;using&lt;/span&gt; Windows.UI.Xaml;
&lt;span class="kwrd"&gt;using&lt;/span&gt; Windows.UI.Xaml.Media;
&lt;span class="kwrd"&gt;using&lt;/span&gt; Windows.UI.Xaml.Shapes;

&lt;span class="kwrd"&gt;namespace&lt;/span&gt; WinRTBehaviorTest
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ChangeColorBehavior : Behavior&amp;lt;Rectangle&amp;gt;
    {
        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnAttached()
        {
            &lt;span class="kwrd"&gt;base&lt;/span&gt;.OnAttached();
            AssociatedObject.PointerPressed += (sender, args) =&amp;gt; AssociatedObject.Fill = &lt;span class="kwrd"&gt;new&lt;/span&gt; SolidColorBrush(PressedColor);
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; Color PressedColor
        {
            get { &lt;span class="kwrd"&gt;return&lt;/span&gt; (Color)GetValue(PressedColorProperty); }
            set { SetValue(PressedColorProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;); }
        }

        &lt;span class="rem"&gt;// Using a DependencyProperty as the backing store for PressedColor.  This enables animation, styling, binding, etc...&lt;/span&gt;
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty PressedColorProperty =
            DependencyProperty.Register(&lt;span class="str"&gt;&amp;quot;PressedColor&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Color), &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(ChangeColorBehavior), 
            &lt;span class="kwrd"&gt;new&lt;/span&gt; PropertyMetadata(Colors.Red));
    }
}&lt;/pre&gt;
&lt;p&gt;
&lt;style&gt;&lt;/style&gt;
&lt;style&gt;&lt;/style&gt;
&lt;/p&gt;
&lt;p&gt;Now, let&amp;rsquo;s create a simple &lt;span style="text-decoration:line-through;"&gt;Metro&lt;/span&gt; Windows Store app in Blend, and add a Rectangle:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_5831A304.png"&gt;&lt;img height="242" width="379" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_29D81D57.png" alt="image" border="0" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" title="image" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To add our behavior, first select the Rectangle, then look for the Interaction.Behaviors attached property in the Properties panel:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_5E787992.png"&gt;&lt;img height="192" width="349" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_652B8315.png" alt="image" border="0" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" title="image" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Press the &amp;hellip; button:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_1003E728.png"&gt;&lt;img height="513" width="494" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_7DBB2065.png" alt="image" border="0" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" title="image" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Select &amp;lt;Other Type&amp;gt; from the Drop down:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_046E29E9.png"&gt;&lt;img height="404" width="404" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_164ABDB6.png" alt="image" border="0" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" title="image" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Notice that Blend has already filtered all the types in our application and shown as those that inherit from Behavior&amp;lt;T&amp;gt;. You may want to do a search here, but we don&amp;rsquo;t need that since this is a simple project. Select ChangeColorBehavior here, and press OK, then press the Add button.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_6F107480.png"&gt;&lt;img height="604" width="604" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_3CACA101.png" alt="image" border="0" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" title="image" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Our behavior is now listed and editable! However, since the Behavior class is a descendant of the FrameWorkElement class (in order to allow bindings), there are a lot of unused properties here. I&amp;rsquo;ll try to address this issue later, but for now, let&amp;rsquo;s be happy that the PressedColor property is visible, and also editable:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_5C5B7AC9.png"&gt;&lt;img height="604" width="604" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_74EB1819.png" alt="image" border="0" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" title="image" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;When you&amp;rsquo;re done, press OK, and let&amp;rsquo;s see how the application runs.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_267685AF.png"&gt;&lt;img height="154" width="244" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_2D298F32.png" alt="image" border="0" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;display:inline;padding-right:0px;border-top-width:0px;" title="image" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Then press on the rectangle:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_260A52BA.png"&gt;&lt;img height="154" width="244" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_2CBD5C3D.png" alt="image" border="0" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;display:inline;padding-right:0px;border-top-width:0px;" title="image" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Yaay! &lt;/p&gt;
&lt;p&gt;By the way, thanks to the shared XAML visual editor in Visual Studio 2012 and Blend 5, the above also works in Visual Studio:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_0178C536.png"&gt;&lt;img height="193" width="244" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_798122D3.png" alt="image" border="0" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;display:inline;padding-right:0px;border-top-width:0px;" title="image" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ll dig deeper into Behaviors and Blend and I&amp;rsquo;ll try to make them even easier to use for a non-developer without touching XAML. This is just the first step, stay tuned!&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;span style="text-decoration:line-through;"&gt;Note: the above code has already been checked in to CodeProject. Next, Joost will release a new version and update the NuGet package. Until that happens, you have to download the &lt;/span&gt;&lt;a target="_blank" href="http://winrtbehaviors.codeplex.com/SourceControl/list/changesets"&gt;&lt;span style="text-decoration:line-through;"&gt;source code of WinRTBehaviors&lt;/span&gt;&lt;/a&gt;&lt;span style="text-decoration:line-through;"&gt;.&lt;/span&gt; Update: Joost has updated the NuGet package, all cool &lt;img src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/wlEmoticon_2D00_smile_5F00_1867BC7F.png" alt="Smile" style="border-top-style:none;border-left-style:none;border-bottom-style:none;border-right-style:none;" class="wlEmoticon wlEmoticon-smile" /&gt;&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=6313" width="1" height="1"&gt;</content><author><name>vbandi</name><uri>http://dotneteers.net/members/vbandi/default.aspx</uri></author></entry><entry><title>Using NUnit to test Windows Phone 7 applications Part 3: ViewModels and MVVM Light Toolkit</title><link rel="alternate" type="text/html" href="/blogs/vbandi/archive/2012/08/17/using-nunit-to-test-windows-phone-7-applications-part-3-viewmodels-and-mvvm-light-toolkit.aspx" /><id>/blogs/vbandi/archive/2012/08/17/using-nunit-to-test-windows-phone-7-applications-part-3-viewmodels-and-mvvm-light-toolkit.aspx</id><published>2012-08-17T00:40:59Z</published><updated>2012-08-17T00:40:59Z</updated><content type="html">&lt;p&gt;&lt;em&gt;In the previous posts of &lt;/em&gt;&lt;a href="http://dotneteers.net/blogs/vbandi/archive/tags/WP7+Nunit/default.aspx" target="_blank"&gt;&lt;em&gt;this series&lt;/em&gt;&lt;/a&gt;&lt;em&gt;, we managed to get NUnit up and running to test WP7 code outside of the Windows Phone Emulator, in test runners such as NUnit, ReSharper and NCrunch, but paid the price by running into assembly load issues. We created a TestBase class to be the base class for our classes, and added convenience functions to it such as setting a global General.IsTesting flag, comparing arrays and verifying whether INotifyPropertyCollection calls have been performed properly.&lt;/em&gt; &lt;/p&gt;  &lt;p&gt;In this post, I am going to concentrate on testing ViewModels that use Laurent Bugnion’s &lt;a href="http://mvvmlight.codeplex.com/" target="_blank"&gt;MVVM Light Toolkit&lt;/a&gt;. &lt;/p&gt;  &lt;h2&gt;&lt;/h2&gt;  &lt;h2&gt;Adding MVVM Light to the Project&lt;/h2&gt;  &lt;p&gt;Let’s start by adding MVVM Light from Nuget (I am using only the libraries for now): &lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_0EA4C97A.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_273466CA.png" width="636" height="380" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now we can change our Calculator class to inherit from ViewModelBase. Which also means that we can get rid of our existing PropertyChanged event and its RaisePropertyChanged invoker method as well, since they are implemented in one of our base classes.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Note: to compile the project, you’ll also have to add the MVVM Light dlls to the Test project.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;All our tests still pass, proving that MVVM Light’s RaisePropertyChanged method works just like ours did. Phew.&lt;/p&gt;  &lt;h2&gt;Verifying Design Mode&lt;/h2&gt;  &lt;p&gt;The ViewModelBase class in MVVM Light has a very useful IsInDesignMode property that allows us to determine if the code is running in a design tool, and do things like creating fake test data for the designer to use instead of empty TextBoxes and Lists. This property can also be used to make sure that you are not trying to access a database from within Blend by making sure you only connect to the database or cloud service when the app is running “for real”.&lt;/p&gt;  &lt;p&gt;Unfortunately, as soon as you access the IsInDesignMode property, the unit tests crash: &lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_1B327696.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_0CF3FDA6.png" width="690" height="307" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This looks awfully like the crash we experienced in the previous part with ObservableCollections. The actual reason is that the setter of this property accesses the DesignerProperties.IsInDesignTool property, which causes an assembly load failure. The solution is pretty similar: we have to make sure the IsInDesignMode never gets called. We can do this by first checking for our General.IsTesting property:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; Calculator()
{
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (!General.IsTesting &amp;amp;&amp;amp; IsInDesignMode)
    {
        &lt;span class="rem"&gt;//do design time setup&lt;/span&gt;

    }
    &lt;span class="kwrd"&gt;else&lt;/span&gt;
    {
        &lt;span class="rem"&gt;//do normal initialization&lt;/span&gt;
    }
}&lt;/pre&gt;

&lt;p&gt;And the tests pass again. Alternatively, if Laurent provides us with a way to set the IsInDesignMode property from our tests, we could simply set that and the code would never have to access DesignerProperties.IsInDesignTool.&amp;#160; &lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;h2&gt;Verifying if Message is sent&lt;/h2&gt;

&lt;p&gt;Messaging has to be one the my favorite features of MVVM Light Toolkit. It allows loose coupling of ViewModels, sometimes even Views without having to worry about memory leaks. &lt;/p&gt;

&lt;p&gt;When testing, you probably want to make sure that your ViewModel has sent (or hasn’t sent) a Message. Luckily, Laurent made the Messaging infrastructure extensible for exactly this reason. We can create a MessengerSpy class, which logs every message that has ever been sent through the Messenger.
  &lt;br /&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; MessengerSpy : Messenger
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;object&lt;/span&gt;&amp;gt; SentMessages = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;object&lt;/span&gt;&amp;gt;();

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; HasSentMessage&amp;lt;T&amp;gt;()
    {
        &lt;span class="kwrd"&gt;return&lt;/span&gt; SentMessages.Any(o =&amp;gt; o &lt;span class="kwrd"&gt;is&lt;/span&gt; T);
    }


    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Send&amp;lt;TMessage&amp;gt;(TMessage message)
    {
        SentMessages.Add(message);
    } 
}&lt;/pre&gt;
  &lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;Note that the message doesn’t actually get sent, only stored. The reason is that we would run into another one of those pesky assembly load failures.&lt;/p&gt;

&lt;p&gt;In the TestBaseSetup method, we use this spy class and set it up so that a new spy is created for every test:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;//set up message logging&lt;/span&gt;
messengerSpy= &lt;span class="kwrd"&gt;new&lt;/span&gt; MessengerSpy();
Messenger.OverrideDefault(_msngr);&lt;/pre&gt;

&lt;p&gt;So, how do we use this? Suppose we want to send a message whenever X changes in the Calculator ViewModel. We have an XChangedMessage for this purpose:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; XChangedMessage
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; NewX { get; set; }
}&lt;/pre&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Since TestBase.messengerSpy is declared protected, it can be accessed from our tests. To make sure the message has been sent, we can simply use the HasSentMessage method:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;[Test]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; XChangedMessageShouldBeSentAfterXChanges()
{
    _calc.X = 10;
    Assert.IsTrue(&lt;span class="kwrd"&gt;base&lt;/span&gt;.messengerSpy.HasSentMessage&amp;lt;XChangedMessage&amp;gt;());
}&lt;/pre&gt;

&lt;p&gt;This fails until we append the following line to the setter of the Calculator.X property:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;Messenger.Default.Send(&lt;span class="kwrd"&gt;new&lt;/span&gt; XChangedMessage());&lt;/pre&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;If we want to go one step further and verify that the NewX value is set properly, then we can do the following:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;[Test]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; XChangedNewXShouldBeSentAfterXChanges()
{
    _calc.X = 10;
    Assert.IsTrue(messengerSpy.SentMessages.Any(m =&amp;gt; ((XChangedMessage)m).NewX == 10));
}&lt;/pre&gt;

&lt;p&gt;&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;And of course, to make this one pass, we have to set the value of NewX in the X setter when the message is created:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;Messenger.Default.Send(&lt;span class="kwrd"&gt;new&lt;/span&gt; XChangedMessage {NewX = 10});&lt;/pre&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;h2&gt;Testing RelayCommands&lt;/h2&gt;

&lt;p&gt;Fortunately, testing RelayCommands is straightforward. Let’s create a ResetXToZero command (which should not be executable when X is already 0) like this: &lt;/p&gt;

&lt;pre class="csharpcode"&gt; ResetXToZero = &lt;span class="kwrd"&gt;new&lt;/span&gt; RelayCommand(() =&amp;gt; X = 0, () =&amp;gt; X != 0);&lt;/pre&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;We can easily test it using the funky Sequential test attribute for zero, positive and negative X values:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;[Test, Sequential]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; VerifyExecuteResetXCanExecute(
    [Values(0, 1, -1)] &lt;span class="kwrd"&gt;int&lt;/span&gt; x,
    [Values(&lt;span class="kwrd"&gt;false&lt;/span&gt;, &lt;span class="kwrd"&gt;true&lt;/span&gt;, &lt;span class="kwrd"&gt;true&lt;/span&gt;)] &lt;span class="kwrd"&gt;bool&lt;/span&gt; expected
    )
{
    _calc.X = x;
    Assert.AreEqual(expected, _calc.ResetXToZero.CanExecute(&lt;span class="kwrd"&gt;null&lt;/span&gt;));
}&lt;/pre&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;h2&gt;Summary&lt;/h2&gt;

&lt;p&gt;This concludes my short blog series on using NUnit to test Windows Phone applications. As you can see, the method outlined here has quite a few issues, especially when you want to load assemblies beyond the basics. However, this technique was extremely useful for me during our last project, where complex calculations had to be tested that did not rely on any platform-specific functionality – but still took advantage of the Math functions and a huge amount of Linq expressions, IQueriables, etc.&lt;/p&gt;

&lt;h2&gt;Source Code&lt;/h2&gt;

&lt;p&gt;You can download the source code for this little project &lt;a href="https://skydrive.live.com/redir?resid=F107151F293B6EB6!4287&amp;amp;authkey=!AHrUWvEgsisM0FY" target="_blank"&gt;here&lt;/a&gt;. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=6231" width="1" height="1"&gt;</content><author><name>vbandi</name><uri>http://dotneteers.net/members/vbandi/default.aspx</uri></author><category term="WP7 Nunit" scheme="http://dotneteers.net/blogs/vbandi/archive/tags/WP7+Nunit/default.aspx" /></entry><entry><title>Using NUnit to test Windows Phone 7 applications – Part 2</title><link rel="alternate" type="text/html" href="/blogs/vbandi/archive/2012/08/12/using-nunit-to-test-windows-phone-7-applications-part-2.aspx" /><id>/blogs/vbandi/archive/2012/08/12/using-nunit-to-test-windows-phone-7-applications-part-2.aspx</id><published>2012-08-12T16:11:44Z</published><updated>2012-08-12T16:11:44Z</updated><content type="html">&lt;p&gt;In the previous post of &lt;a href="http://dotneteers.net/blogs/vbandi/archive/tags/WP7+Nunit/default.aspx" target="_blank"&gt;this series&lt;/a&gt;, we managed to get NUnit up and running to test WP7 code outside the Windows Phone emulator, in test runners such as NUnit, Resharper or Ncrunch. In this post, we pay the price for that as we move on to more complicated tests. I’ll focus on ObservableCollections and the INotifyPropertyChanged in this post.&lt;/p&gt;  &lt;h2&gt;&lt;/h2&gt;  &lt;h2&gt;&lt;/h2&gt;  &lt;h2&gt;ObservableCollection gotchas&lt;/h2&gt;  &lt;p&gt;Suppose we want to extend our calculator with a simple function that returns all positive integers until a given number. We start implementing the tests:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;[Test]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; PositivesUntil0ShouldBeEmpty()
{
    _calc.X = 0;
    Assert.AreEqual(0, _calc.PositiveIntsUntilX.Count);
}&lt;/pre&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Of course, this doesn’t compile yet, we need the X and the PositiveIntsUntilX properties. Since later we want the Calculator to act as a ViewModel, and bind directly to it, the PositiveIntsUntilX should be an ObservableCollection, to be recalculated whenever X changes. But we’re not there yet, just trying to do the simplest thing that will make the test pass. This should be it:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; X { get; set; }

&lt;span class="kwrd"&gt;private&lt;/span&gt; ObservableCollection&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; _positivesUntilX = &lt;span class="kwrd"&gt;new&lt;/span&gt; ObservableCollection&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;();

&lt;span class="kwrd"&gt;public&lt;/span&gt; ObservableCollection&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; PositiveIntsUntilX
{
    get { &lt;span class="kwrd"&gt;return&lt;/span&gt; _positivesUntilX; }
}&lt;/pre&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;And the test fails! More interestingly, it fails when the ObservableCollection is being created. But why?&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_6EC4F460.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_4DD181B9.png" width="527" height="431" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The error message says:&lt;em&gt; SetUp : System.IO.FileNotFoundException : Could not load file or assembly &amp;#39;System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e&amp;#39; or one of its dependencies. The system cannot find the file specified.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The reason for this error is that the unit test runner cannot load the Windows Phone System.Windows dll, and thus throws errors as soon as that dll is referenced. &lt;/p&gt;

&lt;p&gt;Now, you may want to follow &lt;a href="http://www.andriybuday.com/2011/10/wp7-mango-and-nunit-from-console.html" target="_blank"&gt;Andriy Buday’s hints&lt;/a&gt;, and create a copy of your project, linking files to it, and use the real Silverlight runtime at this point. I will examine a different approach – less powerful, but simpler.&lt;/p&gt;

&lt;p&gt;NUnit is confused since it cannot load the dll hosting the ObservableCollection class. But do we really need the ObservableCollection just to make sure the list has the right items? Can’t we just use a simple List&amp;lt;int&amp;gt; object here for testing, and an ObservableCollection in production?&lt;/p&gt;

&lt;p&gt;Turns out, we can. Both ObservableCollection and List implement the IList interface. So, let’s change our code:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; IList&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; _positivesUntilX = General.IsTesting ? (IList&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;) &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;() : &lt;span class="kwrd"&gt;new&lt;/span&gt; ObservableCollection&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;();&lt;/pre&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; IList&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; PositiveIntsUntilX
{
     get { &lt;span class="kwrd"&gt;return&lt;/span&gt; _positivesUntilX; }
}&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;We will also need to create a new global class called General, that lets our code know if it is running in a test environment. This is not nice, and &lt;strong&gt;smells&lt;/strong&gt;, but we’ll take care of that later.&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; General
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; IsTesting = &lt;span class="kwrd"&gt;false&lt;/span&gt;;
}&lt;/pre&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;The Windows Phone Silverlight runtime will still update the ListBox bound to PositiveIntsUntilX, since it detects that there is an ObservableCollection (more precisely, an object implementing the INotifyCollectionChanged interface) behind the ILIst property. And our unit tests never need to create an ObservableCollection, so they pass. &lt;/p&gt;

&lt;h2&gt;&lt;/h2&gt;

&lt;h2&gt;Comparing Lists&lt;/h2&gt;

&lt;p&gt;Next, we want to make sure that the PositiveIntsUntilX list has the right elements for different X values. No special WP7 issues here, but I thought it would be nice to have this here as well… It is useful to have a CompareLists&amp;lt;T&amp;gt; method for these tests. I put the CompareLists method in a TestBase class (which will also be useful later): &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; TestBase
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; CompareLists&amp;lt;T&amp;gt;(IList&amp;lt;T&amp;gt; expected, IList&amp;lt;T&amp;gt; actual)
    {
        Assert.AreEqual(expected.Count, actual.Count);
        &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; expected.Count; i++)
            Assert.AreEqual(expected[i], actual[i]);
    }
}&lt;/pre&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;





&lt;p&gt;Here is the test:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;[Test]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; VerifyPositivesUntil11()
{
    _calc.X = 11;
    CompareLists(&lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, _calc.PositiveIntsUntilX);
}&lt;/pre&gt;

&lt;p&gt;And of course, we have to change the implementations of our Calculator to make the test pass:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; X
{
    get { &lt;span class="kwrd"&gt;return&lt;/span&gt; _x; }
    set
    {
        _x = &lt;span class="kwrd"&gt;value&lt;/span&gt;;
        CalculatePositivesUntilX();
    }
}

&lt;span class="kwrd"&gt;private&lt;/span&gt; IList&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; _positivesUntilX = General.IsTesting ? (IList&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;) &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;() : &lt;span class="kwrd"&gt;new&lt;/span&gt; ObservableCollection&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;();
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; _x;

&lt;span class="kwrd"&gt;public&lt;/span&gt; IList&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; PositiveIntsUntilX
{
    get { &lt;span class="kwrd"&gt;return&lt;/span&gt; _positivesUntilX; }
}

&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; CalculatePositivesUntilX()
{
    _positivesUntilX.Clear();
    &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 1; i &amp;lt;= X; i++)
        _positivesUntilX.Add(i);
}&lt;/pre&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;All green!&lt;/p&gt;

&lt;h2&gt;Verifying that INotifypropertyChanged gets called&lt;/h2&gt;

&lt;p&gt;Most of the time you will have a central, proven mechanism for handling INotifyPropertyChanged in your properties. But sometimes you want to make sure in your tests that these actually get called at the right time. In our little example, we want to make sure that after setting X, the PropertyChanged even is raised for X, but not or PostitiveIntsUntilX – we went through all that trouble making it an ObservableCollection after all…&lt;/p&gt;

&lt;p&gt;Here is the PropertyChanged notification watcher for the TestBase: &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;pre class="csharpcode"&gt;[SetUp]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; TestBaseSetup()
{
    General.IsTesting = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (_propertyNotifications != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
        &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (var key &lt;span class="kwrd"&gt;in&lt;/span&gt; _propertyNotifications.Keys)
            StopMonitoringINotifyPropertyChanged(key);

    _propertyNotifications = &lt;span class="kwrd"&gt;new&lt;/span&gt; Dictionary&amp;lt;INotifyPropertyChanged, List&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;&amp;gt;();
}&lt;/pre&gt;&lt;style&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;span class="kwrd"&gt;protected&lt;/span&gt; Dictionary&amp;lt;INotifyPropertyChanged, List&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;&amp;gt; _propertyNotifications;

&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; MonitorINotifyPropertyChanged(INotifyPropertyChanged vm)
{
    vm.PropertyChanged += OnVMOnPropertyChanged;
}

&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; StopMonitoringINotifyPropertyChanged(INotifyPropertyChanged vm)
{
    vm.PropertyChanged -= OnVMOnPropertyChanged;
}

&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnVMOnPropertyChanged(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, PropertyChangedEventArgs args)
{
    var key = (INotifyPropertyChanged) sender;
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (!_propertyNotifications.ContainsKey(key))
        _propertyNotifications.Add(key, &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;());

    _propertyNotifications[key].Add(args.PropertyName);
}

&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; HasPropertyChangedBeenRaised(INotifyPropertyChanged vm, &lt;span class="kwrd"&gt;string&lt;/span&gt; propertyName)
{
    &lt;span class="kwrd"&gt;return&lt;/span&gt; _propertyNotifications.ContainsKey(vm) &amp;amp;&amp;amp; _propertyNotifications[vm].Contains(propertyName);
}&lt;/pre&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;The NUnit test runner executes the SetUp of the TestBase class first, so all is taken care of by the time we get to running the actual tests. Here is how to test if a PropertyChanged has been raised for our calculator:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;[Test]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; PropertyChangedNotRaisedForX()
{
    MonitorINotifyPropertyChanged(_calc);
    _calc.X = 10;
    Assert.IsTrue(HasPropertyChangedBeenRaised(_calc, &lt;span class="str"&gt;&amp;quot;X&amp;quot;&lt;/span&gt;));
}&lt;/pre&gt;
&lt;style&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;



&lt;p&gt;Of course the above test passes until you actually add the code to raise the event. I’ll leave that to you so that we can focus on the testing now.&lt;/p&gt;

&lt;p&gt;If you want even more detailed verification, you can access all the events in the order they occurred by accessing the _propertyNotifications[_calc] list. This contains all the property names in the order their respective PropertyChanged even has been raised.&lt;/p&gt;

&lt;p&gt;In the next post, I’ll look at the challenges of using Laurent Bugnion’s MVVM Light Toolkit with this Unit testing approach. I’ll give directions on how to handle his IsInDesignMode and Messenger while testing, and also a look at how some of the code smells above can be decreased by using the SimpleIOC container in the Toolkit.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=6222" width="1" height="1"&gt;</content><author><name>vbandi</name><uri>http://dotneteers.net/members/vbandi/default.aspx</uri></author><category term="WP7 Nunit" scheme="http://dotneteers.net/blogs/vbandi/archive/tags/WP7+Nunit/default.aspx" /></entry><entry><title>Using NUnit to test Windows Phone 7 applications – Part 1</title><link rel="alternate" type="text/html" href="/blogs/vbandi/archive/2012/08/08/using-nunit-to-test-windows-phone-7-applications-part-1.aspx" /><id>/blogs/vbandi/archive/2012/08/08/using-nunit-to-test-windows-phone-7-applications-part-1.aspx</id><published>2012-08-08T08:33:17Z</published><updated>2012-08-08T08:33:17Z</updated><content type="html">&lt;p&gt;Unit testing phone applications is not common. Partly, because these applications tend to be UI-focused and there is not too much logic to talk about in the first place. Partly, because the lack of tooling support. I am not a big unit tester myself, since I’ve mostly focused on UX recently. &lt;/p&gt;  &lt;p&gt;However, our latest Windows Phone project simply cried out for unit testing. It has an extremely complicated inner logic with many complexity layers. We had a reference iOS app that we could turn to for verifying the results of the difficult calculations, but not much more. Most new new features increased the difficulty of these calculations by a whole new dimension. We had tons of calculations we need to be sure stayed valid as the code evolved. So, I began to look at Windows Phone unit testing. &lt;/p&gt;  &lt;p&gt;At first, I stumbled upon &lt;a href="http://www.jeff.wilcox.name/2011/06/updated-ut-mango-bits/" target="_blank"&gt;Jeff Wilcox’s Silverlight Unit Test Frameworks&lt;/a&gt;. This is a test harness that runs on a Windows Phone device or the emulator. Here is a screenshot from &lt;a href="http://jesseliberty.com/2011/03/08/silverlight-unit-test-for-phone/" target="_blank"&gt;Jesse Liberty’s intro blog post on the topic&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_0DA05C1A.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_33960C70.png" width="280" height="507" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;There are quite a few pros and cons for this framework. The big pro is that it runs on the actual environment, on the same .NET Compact Framework, etc. as the actual application. This didn’t help me much, since the #1 thing I wanted to test was the calculation logic, which is UI agnostic. The big con is that it doesn’t run in a regular unit test runner. Resharper won’t execute it, you can barely hack it into the build process. But the big turn-off for me was that you can’t double click on a failed test and be taken to the right line of code in Visual Studio. You have to do a lot of code navigation and emulator / phone tapping to run a single test in debug mode to figure out what’s wrong.&lt;/p&gt;  &lt;p&gt;Let’s create a new Windows Phone Class Library, this will be our code being tested, called &lt;strong&gt;TestMe&lt;/strong&gt;:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_67CA35B6.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_4A08AAF7.png" width="640" height="444" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Then, another one, which will contain our tests, called &lt;strong&gt;TestMe.Test&lt;/strong&gt;:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_3D9A87CE.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_6DE15C84.png" width="640" height="442" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Both of them should be Windows Phone 7.1. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_0CB7D063.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_40EBF9A9.png" width="531" height="250" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now, if you want to add the nunit.framework dll to the TestMe.Test project, it will fail. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_04C02E01.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_39608A3C.png" width="478" height="230" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Here is the Message Box text so that search engines can find it:&lt;/p&gt;    &lt;p&gt;---------------------------      &lt;br /&gt;Incompatible reference       &lt;br /&gt;---------------------------       &lt;br /&gt;&amp;quot;nunit.framework, Version=2.6.1.12217, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77&amp;quot; is incompatible with Windows Phone 7.1&lt;/p&gt;    &lt;p&gt;&amp;#160;&lt;/p&gt;    &lt;p&gt;In order to add it you should to change the project&amp;#39;s target to a compatible framework first.      &lt;br /&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;There are a couple of solutions out there for this one. Most include &lt;a href="http://carl-otto.se/2011/01/how-to-add-nunit-to-windows-phone-library/" target="_blank"&gt;manually editing the project files&lt;/a&gt; and other trickery. However, there is a much simpler solution – use NuGet! Instead of adding the nunit.framework library as a reference, just right click on the project, select Manage NuGet Packages:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_590F6404.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_31D51ACF.png" width="420" height="287" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Then search for NUnit and install it. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_38882452.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_309081F0.png" width="622" height="342" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We don’t get any error messages complaining about incompatible runtimes. I don’t know if this is a bug or feature in the NuGet package manager, but I’m happy it works &lt;img style="border-bottom-style:none;border-left-style:none;border-top-style:none;border-right-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/wlEmoticon_2D00_smile_5F00_7C7BE29C.png" /&gt;&lt;/p&gt;  &lt;p&gt;Reference the TestMe project from the TestMe.Test project, and setup is done. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_755CA624.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_42F8D2A5.png" width="640" height="368" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Let’s write a little bit of test to make sure everything is OK. In the TestMe project, create a Calculator Class:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; TestMe
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Calculator
    {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Add(&lt;span class="kwrd"&gt;int&lt;/span&gt; x, &lt;span class="kwrd"&gt;int&lt;/span&gt; y)
        {
            &lt;span class="kwrd"&gt;return&lt;/span&gt; -1;
        }
    }
}&lt;/pre&gt;

&lt;p&gt;&lt;style&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;And in the TestMe.Test project, let’s write our first test:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; NUnit.Framework;

&lt;span class="kwrd"&gt;namespace&lt;/span&gt; TestMe.Test
{
    [TestFixture]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; CalculatorTests
    {
        &lt;span class="kwrd"&gt;private&lt;/span&gt; Calculator _calc;
        [SetUp]
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; InitTest()
        {
            _calc = &lt;span class="kwrd"&gt;new&lt;/span&gt; Calculator();
        }

        [Test]
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AddingZerosShouldReturnZero()
        {
            &lt;span class="kwrd"&gt;int&lt;/span&gt; result = _calc.Add(0, 0);
            Assert.AreEqual(0, result);
        }

    }
}&lt;/pre&gt;

&lt;p&gt;&lt;style&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;Obviously, this test should fail. But what kind of Test Runners can we use to verify that?&lt;/p&gt;

&lt;p&gt;We can use the Nunit test runner, but that hasn’t been installed with the NuGet that we performed above. But we can also use Resharper, which flawlessly recognizes the&amp;#160; tests:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_66B1FA3F.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_6D6503C2.png" width="481" height="420" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And we can also use &lt;a href="http://www.ncrunch.net/" target="_blank"&gt;NCrunch&lt;/a&gt;, my new favorite test runner tool, which runs the tests as you type, and provides you almost instantaneous feedback.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_455254A3.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_60F6E099.png" width="462" height="363" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And of course, we can just select a test, debug it and stop on any breakpoint:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_12161B3A.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_51E001BF.png" width="344" height="186" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: it is not the goal of this post to teach you how to do unit testing in general. There are much better sources for that &lt;img style="border-bottom-style:none;border-left-style:none;border-top-style:none;border-right-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/wlEmoticon_2D00_smile_5F00_7C7BE29C.png" /&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now that we have the tooling out of the way, we can start writing Windows Phone unit tests just like we do for the desktop framework… Until… well, until we run into a few gotchas with this method. In the next parts of the series, I will look into how you can handle assembly load failures (these are tough), test ViewModels, and tweak Laurent Bugnion’s &lt;a href="http://mvvmlight.codeplex.com/" target="_blank"&gt;MVVM Light Toolkit&lt;/a&gt; so that it works well with unit testing scenarios.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=6214" width="1" height="1"&gt;</content><author><name>vbandi</name><uri>http://dotneteers.net/members/vbandi/default.aspx</uri></author><category term="Windows Phone 7" scheme="http://dotneteers.net/blogs/vbandi/archive/tags/Windows+Phone+7/default.aspx" /><category term="WP7 Nunit" scheme="http://dotneteers.net/blogs/vbandi/archive/tags/WP7+Nunit/default.aspx" /></entry><entry><title>MVP Again… 5 years and counting!</title><link rel="alternate" type="text/html" href="/blogs/vbandi/archive/2012/07/10/mvp-again-5-years-and-counting.aspx" /><id>/blogs/vbandi/archive/2012/07/10/mvp-again-5-years-and-counting.aspx</id><published>2012-07-09T23:28:03Z</published><updated>2012-07-09T23:28:03Z</updated><content type="html">&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_05434DA5.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_0DC35A97.png" width="562" height="307" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I’ve waited for my MVP badge to arrive before announcing this on my blog: I am an MVP again, for the 5th year in a row!&lt;/p&gt;  &lt;p&gt;The novelty of receiving the famous “&lt;em&gt;Congratulations! We are pleased to present you with the 2012 Microsoft® MVP Award! &lt;/em&gt;” email may fade by the fifth time, but the feeling of being honored by the Award, being humbled by the amazing fellow MVPs I can be associated with, and the whole-day grin on my face does not fade at all. &lt;/p&gt;  &lt;p&gt;Starting my fifth MVP year feels special. Five years is a lot! My son turned five yesterday, and oh boy, has he changed. So has technology. My first MVP award was in the Client App Development category, mostly for my community work with WPF and generally around User Experience. Then along came Silverlight, and I found myself being in the first wave of Silverlight MVPs, and part of such an amazing group that it makes me incredibly proud and humbled at the same time to be among them – and even call some of them friends.&lt;/p&gt;  &lt;p&gt;Last year was a blur (my MVP year is from April to the end of March, with the awards arriving in July). While Silverlight’s best days may be behind it, the spirit lives on. Ever since I heard the first details, I was focused on Windows Phone. I jumped right into it, absorbing the – Silverlight based – development model along with the amazing User Experience it provided. I talked at tons of events about the phone, development, design - including the Hungarian launch of Windows Phone 7, and later the Nokia devices. But the biggest speaker achievement of this last year was that – along with Bálint Orosz, the designer of Cocktail Flow – I could not only go to Mix’11, but also &lt;a href="http://channel9.msdn.com/Events/MIX/MIX11/OPN10" target="_blank"&gt;speak there&lt;/a&gt; about &lt;a href="http://www.facebook.com/SurfCube3D" target="_blank"&gt;SurfCube&lt;/a&gt; (our Innovation Award winner browser for Windows Phone 7). Over 800 “outsider” talks were submitted, 200 put up to vote, and merely 12 made it to the conference. Wow.&lt;/p&gt;  &lt;p&gt;I also got into Kinect. I love the green field UX experiments this amazing piece of technology allows us to perform. To see some of our Kinect work, visit our homepage at &lt;a href="http://www.response.hu"&gt;www.response.hu&lt;/a&gt;. I also got invited to a number of Kinect talks, including a “tour” during the Baltic Tech Days.&lt;/p&gt;  &lt;p&gt;All in all, I gave almost 30 talks last year, many of them abroad. Our Silverlight User Group was transformed to a vibrant trend-watching community, &lt;a href="http://www.facebook.com/groups/vnext.hu/" target="_blank"&gt;vNext.hu&lt;/a&gt;, which is the most active vNext group – not bad from a small country of only 10 million people &lt;img style="border-bottom-style:none;border-left-style:none;border-top-style:none;border-right-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/wlEmoticon_2D00_smile_5F00_0FD03393.png" /&gt;. I also kept blogging &lt;a href="http://vbandi.dotneteers.net" target="_blank"&gt;here&lt;/a&gt;, posted 23 articles about Kinect, Windows Phone and User Experience. But the writing didn’t stop there: I wrote an e-book called &lt;a href="http://www.silverlightshow.net/ebooks/wp7_for_silverlight_developers.aspx" target="_blank"&gt;Windows Phone book for Silverlight Developers&lt;/a&gt;, the performance chapter of the first Hungarian Windows Phone book, and also a chapter for a Wrox book which was later pulled due to scheduling conflicts. And these are just the highlights…&lt;/p&gt;  &lt;p&gt;What’s next for this year? I will keep following my passion and interest in technology. That’s the only way to do it. I’ll keep working with Windows Phone 7, while looking forward to Windows Phone 8. Windows 8 will definitely be a big part of my activities, the new tablet form factor and the Metro design language are very exciting. Kinect is also something that I plan to work with and share my thoughts on – both here, on &lt;a href="http://www.twitter.com/vbandi" target="_blank"&gt;Twitter&lt;/a&gt; and also on conferences as a speaker. &lt;/p&gt;  &lt;p&gt;Here’s to another five years!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=6190" width="1" height="1"&gt;</content><author><name>vbandi</name><uri>http://dotneteers.net/members/vbandi/default.aspx</uri></author></entry><entry><title>Windows Phone Performance - Part 5 of many: A Developer’s look at the Nokia Lumia 610</title><link rel="alternate" type="text/html" href="/blogs/vbandi/archive/2012/05/31/windows-phone-performance-part-5-of-many-a-developer-s-look-at-the-nokia-lumia-610.aspx" /><id>/blogs/vbandi/archive/2012/05/31/windows-phone-performance-part-5-of-many-a-developer-s-look-at-the-nokia-lumia-610.aspx</id><published>2012-05-31T12:31:40Z</published><updated>2012-05-31T12:31:40Z</updated><content type="html">&lt;p&gt;&lt;em&gt;The plan for part 5 was to continue my &lt;a href="http://dotneteers.net/blogs/vbandi/archive/tags/WP+Performance/default.aspx" target="_blank"&gt;WP Performance series&lt;/a&gt; with a discussion of List performance. However – as it usually happens - &lt;strong&gt;Life &lt;/strong&gt;has came and changed the plan. First, Oren Nachman published a great article on The Windows Phone Developer Blog called “&lt;/em&gt;&lt;a href="http://windowsteamblog.com/windows_phone/b/wpdev/archive/2012/05/16/listbox-why-art-thou-blanking.aspx" target="_blank"&gt;&lt;em&gt;Listbox, Why Art Thou Blanking&lt;/em&gt;&lt;/a&gt;&lt;em&gt;”, and I don&amp;#39;t really have too much to add to what he wrote. But also, I happened to get a Nokia Lumia 610 phone to test some of the applications we are working on. The 610 (and other, so-called Tango devices) will have a big impact on the lives of Windows Phone developers, but most of have never seen one first hand. I cannot give you one, but I am trying to do the next best thing: I will share experiences with the device and the results of some measurements that I performed so that you can get a feel for the performance characteristics.&lt;/em&gt;&lt;/p&gt;  &lt;h2&gt;The Nokia Lumia 610&lt;/h2&gt;  &lt;p&gt;The Lumia 610 is the first “Tango” device. Tango is the codename for the Windows Phone 7.5 Refresh (build 7.10.8773.98), but you will not catch a Microsoftee call it Tango officially. As an OS update, Tango only brings a handful of small features to Windows Phone. The big change is that Tango has been optimized for phones that have as little as 256 MBytes of RAM available. And that is exactly what the Lumia 610 has. The other notable difference (from a developer’s point of view) is that the 610 has an 800 MHz CPU (the first generation devices had 1GHz, and most of the second generation phones have a 1.4-1.5 GHz CPU).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/WP_5F00_000433_5F00_09C05986.jpg"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="WP_000433" border="0" alt="WP_000433" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/WP_5F00_000433_5F00_thumb_5F00_3C43B6F8.jpg" width="265" height="354" /&gt;&lt;/a&gt;    &lt;br /&gt;&lt;em&gt;The Nokia Lumia 610&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;The Lumia 610 is a very good-looking device – especially the black-white combination that you can see above. It looks better than the much more capable Lumia 710. The Tango OS also performs nicely – you can barely say that the OS runs on a low-specs device, as long as you are using the native features of the operating system. The looks and low price, great in-store performance (where you mostly play with the OS) will probably make it a hit among those who are looking to enter the world of smartphones. &lt;/p&gt;  &lt;p&gt;Things change dramatically when you start third party applications. At this point, you will notice that some applications take forever to load, and for more complicated apps, you will experience glitchy scrollings, blankings, slow response time and even occasional freezes for a second.&lt;/p&gt;  &lt;h2&gt;&lt;/h2&gt;  &lt;h2&gt;Application Loading / CPU performance&lt;/h2&gt;  &lt;p&gt;In the second part of this series (&lt;a href="http://dotneteers.net/blogs/vbandi/archive/2012/02/18/windows-phone-performance-part-2-of-many-it-s-full-of-stars.aspx" target="_blank"&gt;It&amp;#39;s Full of Stars!&lt;/a&gt;), I dealt with application startup times. Let’s see how three phones measure up in this test: the Lumia 610, the LG Optimus 7 and the Lumia 800.&lt;/p&gt;  &lt;p&gt;I tested the star drawing app on all devices. The LG Optimus 7 is a decent first generation Windows Phone, with 1GHz CPU. The Lumia 800 is a second generation device, with 1.4GHz CPU. Both of these have 512 MBytes of RAM. As I mentioned before, the Lumia 610 has an 800 MHz CPU with 256Mbyte RAM. Just for kicks, I also included the values measured on the Emulator.&lt;/p&gt;  &lt;p&gt;The first column of the table shows how many stars (small ellipses) are drawn, and the other columns show the number of milliseconds it took to launch the application. The stars are drawn on the UI thread at startup, so this drawing delays the startup time of the app.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_2679CE9B.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_2D2CD81E.png" width="395" height="180" /&gt;&lt;/a&gt;    &lt;br /&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_1A77DE67.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_3A26B82F.png" width="417" height="249" /&gt;&lt;/a&gt;&lt;em&gt;     &lt;br /&gt;Silverlight Layout and Ellipse rendering performance on the Nokia Lumia 610, Nokia Lumia 800 and the LG Optimus 7.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The results are surprising, but clearly show how efficient the CPU in the Lumia 610 is. Despite the 20% lower CPU clock, the Lumia 610 could easily match the performance of the LG Optimus 7. It could even draw 20,000 stars, which the Optimus 7 couldn’t finish in 20 seconds, so the OS killed the app!&lt;/p&gt;  &lt;p&gt;This is of course by no means a comprehensive test of the CPU. But it is a fairly good indicator on what you can expect from the Lumia 610 in Silverlight – the test app exercises the layout and rendering subsystems of Silverlight, which are key to any application.&lt;/p&gt;  &lt;h2&gt;GPU Performance&lt;/h2&gt;  &lt;p&gt;To measure the raw CPU performance, I used the “Fill Rate Test Sample” from the MSDN article &lt;a href="http://msdn.microsoft.com/en-us/library/ff967560(v=VS.92).aspx" target="_blank"&gt;Performance Considerations in Applications for Windows Phone&lt;/a&gt;. This does not test things like shaders, perspective transformations, etc – but it is a good first indicator. I gradually increased the number of rectangles on the screen, which in turn increased the fill rate. As we saw in part 4 of this series, &lt;a href="http://www.dotneteers.net/blogs/vbandi/archive/2012/03/22/windows-phone-performance-part-4-of-many-the-power-of-the-gpu.aspx" target="_blank"&gt;The Power of the GPU&lt;/a&gt;, Fill Rate is an important measurement for how much work the GPU has to do, and a high Fill Rate makes the FPS (frame per seconds) drop. Without further ado, here are the results in table and chart format:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_322F15CD.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_17EEACA9.png" width="526" height="667" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_490DE749.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_21D39E14.png" width="524" height="315" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Fill Rate vs FPS on the Nokia Lumia 610, Nokia Lumia 800 and the LG Optimus 7&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;As you can see, the Lumia 610 not just matches, but seriously outperforms the first generation Optimus 7, delivering almost twice as many frames per second under heavy load! The Lumia 800 has 75% higher CPU and GPU speed than the 610, and it performs accordingly. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The FPS starts to drop at the Fill Rate of only 2.5 for the Optimus 7&lt;/strong&gt; (which is tuned to a maximum frame rate of 50 instead of the usual 60). At this point, the list scrolling becomes somewhat choppy – it begins to jump a little bit every second or so, while remaining completely smooth in between. This is a very low value – it barely gives you enough space to put a background image and a full screen of information on top of it. E.g. if you have a Panorama app where you want to put a semi-transparent background behind your content, you are already at the edge.&lt;strong&gt; The first cutoff points are much further for the 610 – at a Fill Rate of 4&lt;/strong&gt;. This means that the 610 can manipulate 1.5 more screens worth of pixels without any visible glitch. Of course, &lt;strong&gt;the Lumia 800 wins here again, which can almost go up until a Fill Rate of 8&lt;/strong&gt; before the first signs of strain start to show.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The pain point (where the frame rate drops below 30 FPS) comes way too early on the Optimus 7 – at a Fill Rate of 5&lt;/strong&gt;, we are already in the red zone. The 610 can handle 70% more pixels before dropping below 30 FPS, at a Fill Rate of 8.5, while the 800 can soar up to a Fill Rate of 15. &lt;/p&gt;  &lt;h2&gt;Memory&lt;/h2&gt;  &lt;p&gt;So, the Lumia 610 CPU is on par with first generation devices, and the GPU is much better. Why did I say then that the performance of the Lumia 610 is not perfect? It all comes down to lack of memory.&lt;/p&gt;  &lt;p&gt;Microsoft has done an awesome job shoehorning the Windows Phone 7.5 Mango OS into 256Mbytes. The only feature they had to remove are the background tasks, and some media codecs (see the details at &lt;a href="http://windowsteamblog.com/windows_phone/b/wpdev/archive/2012/04/17/handle-feature-reductions.aspx" target="_blank"&gt;Handle Feature Reductions&lt;/a&gt;). But while apps on 512Mbyte phones have a lot of memory to play with, apps on 256 MByte phones only get 60 MBytes. Tango improved virtual memory (paging), which means that your application still can use up to 90 MBytes of memory, only the data above 60 MBytes gets swapped out. When this happens between two screens, all the user sees is some delay between the screens. But when it happens while you are still on one screen, the app seems to freeze and does not react to user input. This usually takes about a second, which is more than enough to cause frustration in the user. &lt;/p&gt;  &lt;p&gt;There are some great posts by Mike Battista on &lt;a href="http://windowsteamblog.com/windows_phone/b/wpdev/archive/2012/03/07/optimizing-apps-for-lower-cost-devices.aspx" target="_blank"&gt;Optimizing Apps for Lower Cost Devices&lt;/a&gt; that cover what you can do to help this situation. You can get to a fairly decently performing app following his directions. However, if you are using things like the WebBrowserControl or the BingMaps control (and can’t replace them with a call to the appropriate OS task), you are out of luck. No matter what you do, these controls take up too much memory. For example, a simple app only with only a WebBrowserControl can easily consume as much as 50-52 MBytes of RAM, which doesn’t leave much space until the swapping starts to happen.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/WP_5F00_000441_5F00_754A6E2D.jpg"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="WP_000441" border="0" alt="WP_000441" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/WP_5F00_000441_5F00_thumb_5F00_1D99A082.jpg" width="290" height="387" /&gt;&lt;/a&gt;&lt;em&gt;     &lt;br /&gt;Lumia 610 loading a complicated web page in a simple app, occupying 56 MBytes of RAM (which later goes down to 42) out of the available 60.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;To see what the low memory means for a more complex app that uses the WebBrowserControl, check out this video. Note, that I do not load anything beyond a basic text file into the browser – if I did, the 610 would load up unbearably slow.&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:d354a50e-e410-465d-b5f1-87918f95cb92" class="wlWriterEditableSmartContent"&gt;&lt;div&gt;&lt;object width="448" height="252"&gt;&lt;param name="movie" value="http://www.youtube.com/v/bNmV_rmxn3I?hl=en&amp;amp;hd=1"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/bNmV_rmxn3I?hl=en&amp;amp;hd=1" type="application/x-shockwave-flash" width="448" height="252"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;&lt;div style="width:448px;clear:both;font-size:.8em;"&gt;Launching SurfCube on LG Optimus 7 and Nokia Lumia 610&lt;/div&gt;&lt;/div&gt;  &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;The Lumia 610 is a surprisingly powerful device that easily matches the first generation Windows Phones and even outperforms them when it comes to graphics. However, the lack of memory kills the joy – a slightly more complicated app can easily find itself being swapped out, resulting in slow app launches, responsivity issues and temporary freezes due to paging. Despite the fairly powerful GPU and CPU, it takes significant developer effort to match the user experience of apps when compared to first generation devices – if at all possible.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=6118" width="1" height="1"&gt;</content><author><name>vbandi</name><uri>http://dotneteers.net/members/vbandi/default.aspx</uri></author><category term="Windows Phone 7" scheme="http://dotneteers.net/blogs/vbandi/archive/tags/Windows+Phone+7/default.aspx" /><category term="WP Performance" scheme="http://dotneteers.net/blogs/vbandi/archive/tags/WP+Performance/default.aspx" /></entry><entry><title>Zoomcity Budapest – Controlling a 7.2 Gigapixel panorama with Kinect</title><link rel="alternate" type="text/html" href="/blogs/vbandi/archive/2012/03/28/zoomcity-budapest-controlling-a-7-2-gigapixel-panorama-with-kinect.aspx" /><id>/blogs/vbandi/archive/2012/03/28/zoomcity-budapest-controlling-a-7-2-gigapixel-panorama-with-kinect.aspx</id><published>2012-03-28T16:36:21Z</published><updated>2012-03-28T16:36:21Z</updated><content type="html">&lt;p&gt;ZoomCity Budapest is our third Kinect project, and the first that used Microsoft’s Official Kinect for Windows SDK (Although we have upgraded our &lt;a href="http://www.dotneteers.net/blogs/vbandi/archive/2012/03/19/kinect-quiz-for-yaz.aspx" target="_blank"&gt;Kinect Quiz&lt;/a&gt; app to the official SDK, too). &lt;/p&gt;  &lt;p&gt;The software was created in cooperation with &lt;a href="http://www.360world.eu" target="_blank"&gt;360World&lt;/a&gt; (the guys who created the world recorder 70 Gigapixel panorama of Budapest) and &lt;a href="http://www.aera.hu/" target="_blank"&gt;Aera&lt;/a&gt;. &lt;a href="http://www.response.hu" target="_blank"&gt;My company&lt;/a&gt; worked on the Kinect controls, the Silverlight Deep Zoom engine and the user experience. The panning is controlled by the left or the right hand, while zooming is performed by stepping forward (closer to the screen) for zooming in, and stepping backwards for zooming out.&lt;/p&gt;  &lt;p&gt;The application is very easy to learn by following the on-screen instructions, and tuned for an exhibition scenario – it has a narrow “play area” and robust user tracking among other things. We have also created little “step here” markers to help the users. &lt;/p&gt;  &lt;p&gt;Here is the end result:&lt;/p&gt; &lt;iframe height="315" src="http://www.youtube.com/embed/5dZ5XrXrnXY" frameborder="0" width="560"&gt;&lt;/iframe&gt;  &lt;p&gt;Thoughts?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=6075" width="1" height="1"&gt;</content><author><name>vbandi</name><uri>http://dotneteers.net/members/vbandi/default.aspx</uri></author></entry><entry><title>Windows Phone Start Screen Wastes Tons of Screen Real Estate. Or does it?</title><link rel="alternate" type="text/html" href="/blogs/vbandi/archive/2012/03/23/windows-phone-start-screen-wastes-tons-of-screen-real-estate-or-does-it.aspx" /><id>/blogs/vbandi/archive/2012/03/23/windows-phone-start-screen-wastes-tons-of-screen-real-estate-or-does-it.aspx</id><published>2012-03-23T15:17:00Z</published><updated>2012-03-23T15:17:00Z</updated><content type="html">&lt;p&gt;One of the things people say when looking at the Windows Phone Start Screen is that it wastes a lot of Screen Real Estate on the right side.&amp;#160; Here is what I am talking about:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_68FA32B1.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_6102904F.png" width="196" height="371" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;See? The right side is occupied by just a black space with an arrow. &lt;em&gt;“That space could and should be used to display useful information!”&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;One of the reasons for the space on the right side is that if you move the tiles up, the clock doesn’t get obscured:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_2E9EBCD0.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_0BFA7E55.png" width="195" height="371" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;But still, I hear you say… &lt;em&gt;“There is so much wasted space there!”&lt;/em&gt; OK, I’ll play along. What if we enlarge the tiles and don’t care about the clock?&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_4AEBFEF0.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_7A5A6DBC.png" width="195" height="371" /&gt;&lt;/a&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_276F5A8B.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_72162258.png" width="196" height="371" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;See? Compared to the original version, we actually have less information on the screen, despite starting a bit higher up. If I remove the margin entirely, things are even worse:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_2AC0CC66.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_1A6554AD.png" width="195" height="371" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;No whitespace, just a lot of valuable content. Right? But where did the Photo Hub’s tile go? Barely visible, just a few pixels here. And how much value did we get? We can put a few more characters in the tiles without changing the font size, but nothing to call home about. &lt;/p&gt;  &lt;p&gt;OK, but if we do utilize the entire screen, we may be able to put three columns of tiles there, right? &lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_477A417B.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px 8px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_2A4473A4.png" width="196" height="262" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Maybe… these tiles are 152 pixels wide, maybe 10% drop from the current 173. But the fonts on the tiles are getting too small to read easily if you are beyond your twenties… What do you think? Does being able to see the extra 5-6 tile worth it? I personally prefer the current, two column layout, three columns just feel crowded. Maybe if I had a bigger phone and bigger resolution, additional columns would make sense… &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=6066" width="1" height="1"&gt;</content><author><name>vbandi</name><uri>http://dotneteers.net/members/vbandi/default.aspx</uri></author></entry></feed>