<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://dotneteers.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>VBandi's blog : Silverlight, Windows Phone 7</title><link>http://dotneteers.net/blogs/vbandi/archive/tags/Silverlight/Windows+Phone+7/default.aspx</link><description>Tags: Silverlight, Windows Phone 7</description><dc:language>en</dc:language><generator>CommunityServer 2008 (Build: 30417.1769)</generator><item><title>WP7 – Changing Visuals Based on Phone Theme with ThemeToStateBehavior</title><link>http://dotneteers.net/blogs/vbandi/archive/2012/01/29/wp7-changing-visuals-based-on-phone-theme-with-themetostatebehavior.aspx</link><pubDate>Sun, 29 Jan 2012 12:00:31 GMT</pubDate><guid isPermaLink="false">74e06254-0e07-4c08-8611-9f55b924f030:5982</guid><dc:creator>vbandi</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://dotneteers.net/blogs/vbandi/rsscomments.aspx?PostID=5982</wfw:commentRss><comments>http://dotneteers.net/blogs/vbandi/archive/2012/01/29/wp7-changing-visuals-based-on-phone-theme-with-themetostatebehavior.aspx#comments</comments><description>&lt;p&gt;The built-in resources in Windows Phone 7 help a lot with&amp;#160; automatically reflecting the selected theme of the phone. (See my earlier blog post: &lt;a href="http://www.dotneteers.net/blogs/vbandi/archive/2010/09/14/being-theme-aware-in-windows-phone-7-silverlight-apps.aspx" target="_blank"&gt;Being theme aware in Windows Phone 7 Silverlight apps&lt;/a&gt;). However, sometimes you want to be theme aware, but need more than the predefined resources. For example, you may want to have a generally blue background color, but want it to be a dark blue for the dark theme, and a light blue for the light theme. I created a little Behavior that allows you to do just this. &lt;/p&gt;  &lt;p&gt;Here is how to use it:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Create a new WP7 application (or use your existing one)&lt;/li&gt;    &lt;li&gt;Create a new Visual State Group with two Visual States in Expression Blend. Name them however you want, but I like to keep a naming convention for my states:&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_1567FCA9.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_6E2DB373.png" width="263" height="136" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Change the visuals as you like fit for both themes. For example, I changed the background of the LayoutRoot to a dark blue color for the ThemeStates_Dark Visual State, and a light blue color for the Themes_Light state. For fun, I have also changed the page name text to say “dark side” and “light side”&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_14FBC9B4.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_54C5B039.png" width="244" height="131" /&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_7F9E144B.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_5863CB16.png" width="244" height="123" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;To verify what the Light Theme looks like in Blend, you have to switch to the Device panel, and switch the Theme toggle to Light. This will change the values of the resources, and make the default text black.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_461B0454.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_3EFBC7DC.png" width="264" height="29" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;If you are happy with how your app looks in the different themes, just add the ThemeToStateBehavior (code at the bottom) to the root of your visual tree:&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_4CCE0DD7.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_0C97F45D.png" width="266" height="272" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Set the two themes for the dark and light theme in the Properties panel:&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_1E74882A.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_2C46CE25.png" width="266" height="76" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;… And when you launch the app, you will see that it works as desired:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_252791AD.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_16E918BD.png" width="165" height="88" /&gt;&lt;/a&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_3DB72EFD.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_72578B38.png" width="154" height="84" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Based on the &lt;a href="http://bartwullems.blogspot.com/2011/01/windows-phone-7-detecting-wp7-theme.html" target="_blank"&gt;theme detection logic by Bart Wullems&lt;/a&gt;, here is the code for the behavior:&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ThemeToStateBehavior : Behavior&amp;lt;Control&amp;gt;&lt;/pre&gt;

  &lt;pre&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&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;/pre&gt;

  &lt;pre&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;base&lt;/span&gt;.OnAttached();&lt;/pre&gt;

  &lt;pre&gt;        var isLightTheme = (Visibility)Application.Current.Resources[&lt;span class="str"&gt;&amp;quot;PhoneLightThemeVisibility&amp;quot;&lt;/span&gt;] ==&lt;/pre&gt;

  &lt;pre class="alt"&gt;                            Visibility.Visible;&lt;/pre&gt;

  &lt;pre&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        Dispatcher.BeginInvoke(() =&amp;gt;&lt;/pre&gt;

  &lt;pre&gt;                                VisualStateManager.GoToState(AssociatedObject, isLightTheme ? LightState : DarkState,&lt;/pre&gt;

  &lt;pre class="alt"&gt;                                                            &lt;span class="kwrd"&gt;true&lt;/span&gt;));&lt;/pre&gt;

  &lt;pre&gt;    }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;    [CustomPropertyValueEditor(CustomPropertyValueEditor.StateName)]&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; LightState { get; set; }&lt;/pre&gt;

  &lt;pre&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    [CustomPropertyValueEditor(CustomPropertyValueEditor.StateName)]&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; DarkState{ get; set; }&lt;/pre&gt;

  &lt;pre class="alt"&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;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=5982" width="1" height="1"&gt;</description><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Silverlight.net/default.aspx">Silverlight.net</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category></item><item><title>SurfCube on Mango Part 4 – fighting with the ListPicker control</title><link>http://dotneteers.net/blogs/vbandi/archive/2011/09/11/surfcube-on-mango-part-4-fighting-with-the-listpicker-control.aspx</link><pubDate>Sun, 11 Sep 2011 18:16:24 GMT</pubDate><guid isPermaLink="false">74e06254-0e07-4c08-8611-9f55b924f030:5679</guid><dc:creator>vbandi</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://dotneteers.net/blogs/vbandi/rsscomments.aspx?PostID=5679</wfw:commentRss><comments>http://dotneteers.net/blogs/vbandi/archive/2011/09/11/surfcube-on-mango-part-4-fighting-with-the-listpicker-control.aspx#comments</comments><description>&lt;p&gt;On SurfCube, we are using the ListPicker control from the Silverlight for Windows Phone Toolkit. The latest (August 2011) version of this Toolkit has a bug – it doesn’t work in ScrollViewers. It simply does not open. First we thought the problem was with Pivots / Panoramas – then, stripping away the controls one by one, we found that it was actually the ScrollViewer that stole the tap event somehow.&lt;/p&gt;  &lt;p&gt;After that, it was easy to find an existing solution at &lt;a title="http://forums.create.msdn.com/forums/p/90708/543239.aspx#543239" href="http://forums.create.msdn.com/forums/p/90708/543239.aspx#543239"&gt;http://forums.create.msdn.com/forums/p/90708/543239.aspx#543239&lt;/a&gt;. What we did is package the code there into a nice small behavior (sorry for the weird formatting, just want to make sure it fits the screen):&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Interactivity;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; Microsoft.Phone.Controls;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; My3DBrowser.Behaviors&lt;/pre&gt;

  &lt;pre class="alt"&gt;{&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ListpickerInScrollViewerFixBehavior : &lt;/pre&gt;

  &lt;pre&gt;                 Behavior&amp;lt;ListPicker&amp;gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    {&lt;/pre&gt;

  &lt;pre&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;/pre&gt;

  &lt;pre class="alt"&gt;        {&lt;/pre&gt;

  &lt;pre&gt;            &lt;span class="kwrd"&gt;base&lt;/span&gt;.OnAttached();&lt;/pre&gt;

  &lt;pre class="alt"&gt;            AssociatedObject.Tap += ListPickerTap;&lt;/pre&gt;

  &lt;pre&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="kwrd"&gt;bool&lt;/span&gt; isOpen;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;p&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ListPickerTap(&lt;br /&gt;                &lt;span class="kwrd"&gt;object&lt;/span&gt; sender, System.Windows.Input.GestureEventArgs e)&lt;/p&gt;&lt;/pre&gt;

  &lt;pre&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!isOpen)&lt;/pre&gt;

  &lt;pre&gt;            {&lt;/pre&gt;

  &lt;pre class="alt"&gt;                AssociatedObject.Open();&lt;/pre&gt;

  &lt;pre&gt;                isOpen = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;            }&lt;/pre&gt;

  &lt;pre&gt;            &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;            {&lt;/pre&gt;

  &lt;pre&gt;                isOpen = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;            }&lt;/pre&gt;

  &lt;pre&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;    }&lt;/pre&gt;

  &lt;pre&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;&amp;#160;&lt;/p&gt;

&lt;p&gt;And that’s it… just apply this behavior to any ListPicker that doesn’t behave correctly in a ScrollViewer.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: This is not a perfect solution. For example, after the ListPicker opens, the containing scrollviewer should scroll so that it is entirely visible. We “solved” this problem by putting the listpickers on top – if anybody has a better solution, I am all ears (eyes?)&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=5679" width="1" height="1"&gt;</description><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Silverlight.net/default.aspx">Silverlight.net</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/SurfCube+on+Mango/default.aspx">SurfCube on Mango</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Mango/default.aspx">Mango</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/SurfCube/default.aspx">SurfCube</category></item><item><title>SurfCube on Mango Part 1 – Passing the Smoke Test</title><link>http://dotneteers.net/blogs/vbandi/archive/2011/07/05/surfcube-on-mango-part-1-passing-the-smoke-test.aspx</link><pubDate>Tue, 05 Jul 2011 11:46:28 GMT</pubDate><guid isPermaLink="false">74e06254-0e07-4c08-8611-9f55b924f030:5523</guid><dc:creator>vbandi</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://dotneteers.net/blogs/vbandi/rsscomments.aspx?PostID=5523</wfw:commentRss><comments>http://dotneteers.net/blogs/vbandi/archive/2011/07/05/surfcube-on-mango-part-1-passing-the-smoke-test.aspx#comments</comments><description>&lt;p&gt;&lt;em&gt;Note: If you don’t know what SurfCube is and would like to follow this post series: it is a popular Windows Phone 7 web browser with a 3D twist. &lt;a href="http://www.youtube.com/watch?v=NMEBJUKsCSw" target="_blank"&gt;Here is a demo video&lt;/a&gt; you should look at to understand what I am talking about. Better yet, download SurfCube, see for yourself how it works – and if this series is useful for you, please consider buying!&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;I have just submitted SurfCube 3.1 to the WP7 Marketplace yesterday. Just as many other WP7 developers, I am excited about Mango, and with 3.1 out the door (and will hopefully pass the Marketplace digestion process just fine), I was eager to see how SurfCube behaves on the new Mango Beta 2 SDK and on my phone. I have updated my LG Optimus 7 to Mango, and I just love the new OS! It is even more fluid, responsive and delightful than the original WP7 was. However, this post series is not about Mango – it is about my experiences moving an existing and fairly complex app to Mango. &lt;/p&gt;  &lt;h2&gt;Step 0 – running SurfCube 3.1 on Mango&lt;/h2&gt;  &lt;p&gt;So, after installing Mango Beta on the phone, the first thing to try was see how SurfCube ran on it without any changes whatsoever. Here is the good part: scrolling is butter smooth, even the long history list is perfectly responsive. The web browser scrolling was sometimes a bit jerky on Nodo, but it is perfect on Mango. The cube’s rotation is faster, too, although it was pretty good on Nodo already. And the new IE9 engine is noticeably faster. Not just “well, it feels snappier, but it may just be my imagination” faster. More like “wow, that IS fast!” All in all, a huge gain in general performance, smoothness and user experience.&lt;/p&gt;  &lt;p&gt;Of course, multitasking and fast app switching didn’t work. You have to recompile and modify your app a little bit for that. I also had some crashes, especially around viewing videos (more on this later). But the biggest issue is that our context menu didn’t work. Some of SurfCube’s most advanced features are behind the context menu: opening links in new or background tabs, saving images from the web, sharing a page via Twitter or Email, etc. And it doesn’t work at all. It seems like the Javascript “oncontextmenu” event does not work on Mango, not even in Internet Explorer (we are using the WebBrowser control, which relies on IE9 rendering and running scripts). If things don’t get better, this could end in SurfCube losing some of its most useful features in Mango &lt;img style="border-bottom-style:none;border-left-style:none;border-top-style:none;border-right-style:none;" class="wlEmoticon wlEmoticon-sadsmile" alt="Sad smile" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/wlEmoticon_2D00_sadsmile_5F00_1086E62E.png" /&gt; I have been in touch with Microsoft about this issue, so I am hoping this will be resolved in time.&lt;/p&gt;  &lt;h2&gt;Step 1 – Compiling SurfCube for Mango&lt;/h2&gt;  &lt;p&gt;So, to get the multitasking and other new features working, the first step is to recompile your application for Mango. In theory, this should be as easy as flicking this switch to 7.1 in the project’s properties:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_226379FB.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_3E0805F1.png" width="379" height="153" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Then I was greeted with this rather scary dialog:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_40CDBAE4.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_5C7246DA.png" width="492" height="274" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;OK, I am on a different TFS branch anyway, so let’s go for it!&lt;/p&gt;  &lt;p&gt;But it doesn’t build, I get some ambiguous reference errors for GestureEventArgs – no wonder, it was used from the Silverlight Toolkit for Windows Phone 7, and now it is built into the SDK. So I open up the relevant source files, and fix it with some ReSharper magic:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_7C2120A2.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_0DFDB470.png" width="717" height="117" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I am going to go with the Toolkit gesture for now, so I select the second option, and Resharper inserts the code:&lt;/p&gt;  &lt;pre&gt;using GestureEventArgs = Microsoft.Phone.Controls.GestureEventArgs;&lt;/pre&gt;

&lt;p&gt;to the top, and all is right.&lt;/p&gt;

&lt;p&gt;After trying to compile again, I get a warning:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&amp;#39;My3DBrowser.Controls.WatermarkedTextBox.WatermarkProperty&amp;#39; hides inherited member &amp;#39;System.Windows.Controls.TextBox.WatermarkProperty’&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;All right, TextBox now has a Watermark property, we can throw out our own WatermarkedTextBox control. Nice, but I will ignore it for now. But I also got an error:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;error CS1705: Assembly &amp;#39;Microsoft.Expression.Interactions, Version=3.8.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&amp;#39; uses &amp;#39;System.Windows.Interactivity, Version=3.8.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&amp;#39; which has a higher version than referenced assembly &amp;#39;System.Windows.Interactivity, Version=3.7.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&amp;#39;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Well, it looks like some other assemblies have been updated too, like System.Windows.Interactivity. So, let’s replace it:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_621D3AB3.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_3AE2F17E.png" width="513" height="214" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remove it, and add the right version:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_7AACD803.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_210EBB4F.png" width="799" height="461" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By the way, if the above Add Reference dialog is from the &lt;a href="http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef/" target="_blank"&gt;Visual Studio Productivity Power Tools&lt;/a&gt;, which is pretty much a must have tool! &lt;/p&gt;

&lt;p&gt;So, now we can compile, right? Well, yes, it compiles!&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;========== Build: 5 succeeded or up-to-date, 0 failed, 0 skipped ==========&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So, let’s try to run it! It starts, but crashes before the first screen is loaded:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_40516222.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_65DADF83.png" width="450" height="241" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;MarketPlaceSearch Action is the same code &lt;a href="http://dotneteers.net/blogs/vbandi/archive/2011/01/08/behaviors-for-accessing-the-windows-phone-7-marketplace-and-getting-feedback.aspx" target="_blank"&gt;I shared earlier&lt;/a&gt;. What is important right now is that is uses the WP7 RTM, 3.7.5.0 version of the System.Windows.Interactivity dll, and needs to be updated to Mango. The exception is not very helpful – it is not really a type not found, but a type loading error in this case. This class is in a different project, which has to be updated to WP 7.1 as well. After doing that and replacing the reference for the WP7MarketplaceTools project (where the referenced MarketPlaceSearchAction is), we can try compiling and running again:&lt;/p&gt;

&lt;p&gt;Next problem: WrappedException. This is really a mystery to me. After loading the app, the it comes from the UpdateLayout of a WebBrowser Control (which I had to call manually in WP7). Luckily just removing the call seems to work for now, but this definitely is a breaking change (or bug). &lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_3EA0964E.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_7E6A7CD3.png" width="637" height="272" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And finally, the app starts! &lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_44E76CDC.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_36A8F3EC.png" width="252" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;











&lt;p&gt;Or so it seems – because we have another one of the WrappedException error, again. It happens when our AdControl switches visual states at startup:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.Windows.dll!MS.Internal.XcpImports.CheckHResult(uint hr) + 0x1e bytes&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.Windows.dll!MS.Internal.XcpImports.UIElement_UpdateLayout(System.Windows.UIElement element) + 0x10 bytes&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.Windows.dll!System.Windows.UIElement.UpdateLayout() + 0x6 bytes&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Microsoft.Expression.Interactions.dll!Microsoft.Expression.Interactivity.Core.ExtendedVisualStateManager.GoToStateCore(System.Windows.Controls.Control control, System.Windows.FrameworkElement templateRoot, string stateName, System.Windows.VisualStateGroup group, System.Windows.VisualState state, bool useTransitions) + 0x101 bytes&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.Windows.dll!System.Windows.VisualStateManager.GoToState(System.Windows.Controls.Control control, string stateName, bool useTransitions) + 0x52 bytes&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Well, all right – I will deal with this issue later, and turn off the ads for now. Just let me see the app running!&lt;/p&gt;

&lt;p&gt;And it works!&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_4B2E436A.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin: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_036CBA83.png" width="136" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Awesome! Let’s play around a little bit, and test YouTube playback – it crashes. Oh maaaaan. Here is the exception:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_0300878E.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_6F06F4F7.png" width="644" height="265" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Not too helpful, is it? No usable call stack, no source code, and “Unspecified error” is not the most useful exception either. So, let’s put on the Sherlock hat and start to play detective. &lt;/p&gt;

&lt;p&gt;After clicking on the video, the app is supposed to bring up the video player UI. If I disable the code that makes the player visible, the app doesn’t crash. So, the problem must be somewhere in the video player UI! Here is what it looks like in Blend:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_66A31FA0.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_6D562923.png" width="565" height="370" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Oops, not too nice… luckily in Blend, when we edit the code, the designer surface immediately updates. I removed everything in the main Grid to make sure the problem was indeed in it, and the designer was fixed:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_2D200FA9.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_5EAB7D3E.png" width="644" height="405" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, I started to add and remove lines and chunks of code, until I managed to pinpoint the problem: the two Coding For Fun RoundButtons we are using for the “play/pause” and the “fill screen” functions. I removed those, and the app worked, video played. However, I didn’t want to leave it at that, and found out that there actually is a new Coding For Fun Toolkit released along with the Mango Beta 2 SDK. So, I have replaced the toolkit, and behold – we now have a working SurfCube video player! And the new emulator can playback H.264 videos, so I can show you 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_1036EAD4.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_230B6E7E.png" width="644" height="356" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Summary&lt;/h2&gt;

&lt;p&gt;Getting an existing project to run on Mango is certainly not a trivial task with the Beta SDK. Apart from fixing library references, the biggest problem seems to be with the WrappedExceptions and other unspecified errors. These seem to be beta bugs for me, and mostly happen during the layout / measure cycle. But is is nothing a little detective work cannot fix.&lt;/p&gt;

&lt;p&gt;Other than that, Mango is really pleasant from a developer point of view. The apps run much smoother, consume less memory. My biggest problem with lists (which is considered to be the &lt;a href="http://wp7dev.wikispaces.com/#Performance" target="_blank"&gt;Kryptonite of WP7 apps&lt;/a&gt;) is resolved, and 3rd party apps can now feel just as responsive and smooth as their native friends. Just check out the official Twitter app on Mango to see the difference. (my friend, &lt;a href="http://kodierer.blogspot.com/" target="_blank"&gt;René Schulte&lt;/a&gt; recorded a &lt;a href="http://www.youtube.com/watch?feature=player_embedded&amp;amp;v=DivNORSksYE" target="_blank"&gt;comparison video&lt;/a&gt;, too).&lt;/p&gt;

&lt;p&gt;Next up in the blog post series: multitasking, fast app switching, then the real fun begins as I start to add Mango features to SurfCube. What Mango features should SurfCube take advantage of? Let me know in the comments!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=5523" width="1" height="1"&gt;</description><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/SurfCube+on+Mango/default.aspx">SurfCube on Mango</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Mango/default.aspx">Mango</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/SurfCube/default.aspx">SurfCube</category></item><item><title>Response.MVVM is now available via NuGet!</title><link>http://dotneteers.net/blogs/vbandi/archive/2011/03/31/response-mvvm-is-now-available-via-nuget.aspx</link><pubDate>Thu, 31 Mar 2011 10:34:45 GMT</pubDate><guid isPermaLink="false">74e06254-0e07-4c08-8611-9f55b924f030:5263</guid><dc:creator>vbandi</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://dotneteers.net/blogs/vbandi/rsscomments.aspx?PostID=5263</wfw:commentRss><comments>http://dotneteers.net/blogs/vbandi/archive/2011/03/31/response-mvvm-is-now-available-via-nuget.aspx#comments</comments><description>&lt;p&gt;About a year ago, I wrote an article for SilverlightShow, titled “&lt;a target="_blank"&gt;A Designer-friendly Approach to MVVM&lt;/a&gt;”. The article introduced &lt;strong&gt;VSMChangerBehavior&lt;/strong&gt; which allows tying enums in the ViewModel to Visual States in the View. Another Action shown off there is the &lt;strong&gt;CallDataContextMethodAction&lt;/strong&gt;, which calls a method in the DataContext with a twist – if such a method is not found, it can travel up the visual tree, and call the methods there. &lt;/p&gt;  &lt;p&gt;We have used both the &lt;strong&gt;VSMChangerBehavior&lt;/strong&gt; and the &lt;strong&gt;CallDataContextMethodAction&lt;/strong&gt; in many projects since. We fixed a couple of bugs, and today, we are releasing them as a NuGet package to make it easier than ever to add these handy utilities to your project.&lt;/p&gt;  &lt;p&gt;The package supports WPF, Silverlight and Windows Phone 7 projects. We are also publishing another package with a sample control and ViewModel to show off how the workings.&lt;/p&gt;  &lt;p&gt;To add the package to your project, do the following:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Install the latest NuGet package manager from &lt;a href="http://www.nuget.org"&gt;www.nuget.org&lt;/a&gt;. (this package requires V1.2)&lt;/li&gt;    &lt;li&gt;Open a WP7, WPF or Silverlight project&lt;/li&gt;    &lt;li&gt;Right click on References, and click Add Library Package Reference&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_7BEAE5BC.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin: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_06A83D12.png" width="244" height="188" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt; Search for the package called “Response.MVVM”&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_224CC908.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin: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_25EAE3E5.png" width="244" height="164" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Click Install to install the library or the sample. The sample also installs the library, and adds the Samples\Response.MVVM folder to your solution :&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_418F6FDB.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin: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_257EB0F0.png" width="244" height="153" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;To see how it works, add the SampleControl.xaml to your application, and run it. Here it is in a Windows Phone 7 application:&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_41233CE6.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin: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_32E4C3F6.png" width="149" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;That’s it! Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=5263" width="1" height="1"&gt;</description><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/WPF/default.aspx">WPF</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Silverlight.net/default.aspx">Silverlight.net</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Expression+Blend/default.aspx">Expression Blend</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category></item><item><title>Handling WP7 orientation changes via Visual States</title><link>http://dotneteers.net/blogs/vbandi/archive/2011/03/08/handling-wp7-orientation-changes-via-visual-states.aspx</link><pubDate>Tue, 08 Mar 2011 15:14:22 GMT</pubDate><guid isPermaLink="false">74e06254-0e07-4c08-8611-9f55b924f030:5218</guid><dc:creator>vbandi</dc:creator><slash:comments>12</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://dotneteers.net/blogs/vbandi/rsscomments.aspx?PostID=5218</wfw:commentRss><comments>http://dotneteers.net/blogs/vbandi/archive/2011/03/08/handling-wp7-orientation-changes-via-visual-states.aspx#comments</comments><description>&lt;p&gt;It is pretty well known that an app can be notified of the phone’s orientation changes via the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.controls.phoneapplicationframe.orientationchanged(v=vs.92).aspx" target="_blank"&gt;PhoneApplicationFrame.OrientationChanged&lt;/a&gt; event. However, if you are as serious about sharing the work between the designer and the developer as I am, you will not be happy with this – the changing of the layout should be the responsibility of the designer, not the developer. &lt;/p&gt;  &lt;p&gt;Of course, the best way to achieve the different layouts is via Visual States. You can define two states like this in Blend:&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_672D7E51.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_3FF3351C.png" width="374" height="97" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;And move your controls around. For example, in SurfCube V2.2, we wanted to have the tabs and the tab buttons below each other in Portrait mode, but in a totally different arrangement in Landscape.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_66C14B5C.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin: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_1199AF6F.png" width="151" height="244" /&gt;&lt;/a&gt;&amp;#160;&amp;#160;&amp;#160; &lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_516395F4.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin: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_261EFEED.png" width="244" height="165" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In this example, the buttons are placed inside a WrapPanel, and the WrapPanel’s Row and Colums are changed – in Landscape, they are moved to the first column of the second row. You can even throw in some fluid state changes for added effect. This is all nice, but how do you switch between the two states?&lt;/p&gt;  &lt;p&gt;The first idea that comes to mind is to use GotoStateActions, triggered by the OrientationChanged event. Unfortunately, you cannot attach an event to the PhoneApplicationPage:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_65E8E572.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_10C14985.png" width="377" height="110" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;(In the above screenshot, the invisible mouse cursor points to the PhoneApplicationPage.)&lt;/p&gt;  &lt;p&gt;Even if this worked, we would have problems – the tab page shown above is actually a UserControl, which doesn’t have the OrientationChanged event.&lt;/p&gt;  &lt;h2&gt;Behaviors to the rescue!&lt;/h2&gt;  &lt;p&gt;Like so many times before, behaviors are here to save the day. By creating a simple OrientationToStateBehavior (ok, so the name is not so simple), designers can once again have total control over how they want the UI to look in the different orientations. Just attach the behavior to the UserControl:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_378F5FC5.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_7759464A.png" width="297" height="91" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Set up the different states for the different orientations:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_703A09D2.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_3003F058.png" width="340" height="242" /&gt;&lt;/a&gt;&lt;/p&gt;            &lt;p&gt;And that’s it!&lt;/p&gt;  &lt;p&gt;As for the code of the behavior, you can find it below.&lt;/p&gt;  &lt;p&gt;The most interesting parts are:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;OrientationChanged is global for the entire phone, so we are using the main application frame for this. However, the root visual may not be available at the time the behavior gets attached, so we enqueue the setup code into the UI thread via a Dispatcher.BeginInvoke code.&lt;/li&gt;    &lt;li&gt;If you precede your string properties with      &lt;br /&gt;System.Windows.Interactivity.CustomPropertyValueEditor(CustomPropertyEditor.StateName),      &lt;br /&gt;Expression Blend will provide the user with a dropdown menu of the Visual States in the current control.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The rest is pretty self-explanatory, enjoy Windows Phone 7 coding!&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; System;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows;&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; System.Windows.Controls;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Interactivity;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; Microsoft.Phone.Controls;&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;namespace&lt;/span&gt; My3DBrowser.Behaviors&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;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; OrientationToStateBehavior : Behavior&amp;lt;UserControl&amp;gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; OrientationToStateBehavior()&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;            IsEnabled = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&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;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&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;/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;span class="kwrd"&gt;base&lt;/span&gt;.OnAttached();&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;            InitWhenReady();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; InitWhenReady()&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;            PhoneApplicationFrame main;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;            Dispatcher.BeginInvoke(() =&amp;gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;            {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;                main = Application.Current.RootVisual &lt;span class="kwrd"&gt;as&lt;/span&gt; PhoneApplicationFrame;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (main != &lt;span class="kwrd"&gt;null&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;                    main.OrientationChanged += MainOnOrientationChanged;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;                    SetState(main.Orientation);&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;                &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="rem"&gt;//If rootvisual is still not set, wait some more&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  34:  &lt;/span&gt;                    InitWhenReady();&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;/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;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; IsEnabled { get; set; }&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;        [CustomPropertyValueEditor(CustomPropertyValueEditor.StateName)]&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  41:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; PortraitUpStateName { get; set; }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  42:  &lt;/span&gt;        [CustomPropertyValueEditor(CustomPropertyValueEditor.StateName)]&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  43:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; PortraitDownStateName { get; set; }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  44:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  45:  &lt;/span&gt;        [CustomPropertyValueEditor(CustomPropertyValueEditor.StateName)]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  46:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; LandscapeLeftStateName { get; set; }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  47:  &lt;/span&gt;        [CustomPropertyValueEditor(CustomPropertyValueEditor.StateName)]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  48:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; LandscapeRightStateName { get; set; }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  49:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  50:  &lt;/span&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; MainOnOrientationChanged(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, OrientationChangedEventArgs orientationChangedEventArgs)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  51:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  52:  &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (IsEnabled)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  53:  &lt;/span&gt;                SetState(orientationChangedEventArgs.Orientation);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  54:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  55:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  56:  &lt;/span&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SetState(PageOrientation orientation)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  57:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  58:  &lt;/span&gt;            &lt;span class="kwrd"&gt;string&lt;/span&gt; stateName = &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  59:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  60:  &lt;/span&gt;            &lt;span class="kwrd"&gt;switch&lt;/span&gt; (orientation)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  61:  &lt;/span&gt;            {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  62:  &lt;/span&gt;                &lt;span class="kwrd"&gt;case&lt;/span&gt; PageOrientation.PortraitUp:&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  63:  &lt;/span&gt;                    stateName = PortraitUpStateName;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  64:  &lt;/span&gt;                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  65:  &lt;/span&gt;                &lt;span class="kwrd"&gt;case&lt;/span&gt; PageOrientation.PortraitDown:&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  66:  &lt;/span&gt;                    stateName = PortraitDownStateName;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  67:  &lt;/span&gt;                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  68:  &lt;/span&gt;                &lt;span class="kwrd"&gt;case&lt;/span&gt; PageOrientation.LandscapeLeft:&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  69:  &lt;/span&gt;                    stateName = LandscapeLeftStateName;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  70:  &lt;/span&gt;                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  71:  &lt;/span&gt;                &lt;span class="kwrd"&gt;case&lt;/span&gt; PageOrientation.LandscapeRight:&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  72:  &lt;/span&gt;                    stateName = LandscapeRightStateName;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  73:  &lt;/span&gt;                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  74:  &lt;/span&gt;                &lt;span class="kwrd"&gt;default&lt;/span&gt;:&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  75:  &lt;/span&gt;                    &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; ArgumentOutOfRangeException();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  76:  &lt;/span&gt;            }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  77:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  78:  &lt;/span&gt;            VisualStateManager.GoToState(AssociatedObject, stateName, &lt;span class="kwrd"&gt;true&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  79:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  80:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  81:  &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 style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=5218" width="1" height="1"&gt;</description><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Expression+Blend/default.aspx">Expression Blend</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category></item><item><title>Notifyting the ViewModel when a WP7 PivotItem is displayed</title><link>http://dotneteers.net/blogs/vbandi/archive/2011/01/23/notifyting-the-viewmodel-when-a-wp7-pivotitem-is-displayed.aspx</link><pubDate>Sun, 23 Jan 2011 02:49:55 GMT</pubDate><guid isPermaLink="false">74e06254-0e07-4c08-8611-9f55b924f030:5114</guid><dc:creator>vbandi</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://dotneteers.net/blogs/vbandi/rsscomments.aspx?PostID=5114</wfw:commentRss><comments>http://dotneteers.net/blogs/vbandi/archive/2011/01/23/notifyting-the-viewmodel-when-a-wp7-pivotitem-is-displayed.aspx#comments</comments><description>&lt;p&gt;While trying to reduce the loading time for our &lt;a href="http://t.co/buMxEsh" target="_blank"&gt;SurfCube 3D Browser app&lt;/a&gt;, I realized that loading a 100 or so history items to a ViewModel property directly bound to the UI may not be the best idea. It takes up a long time (like 0.5 seconds) to render the items in the list, and the user may never see the history during his / her session. The solution is obviously to load the items only when needed.&lt;/p&gt;  &lt;p&gt;In the upcoming version of SurfCube, we will have a Pivot for choosing between Favorites and History. This is what the top side of the Cube 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_2DCFE959.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_6D2D9CE9.png" width="149" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;For most browsing sessions, the user won’t even visit the history at all. I only want to spend precious CPU cycles on rendering the history when needed. So, I need a way for my ViewModel to know when to actually load the history items to the ObservableCollection bound to the list on the History PivotItem.&lt;/p&gt;  &lt;p&gt;Unfortunately, the PivotItem control does not expose any event that fires when it is activated. Technically, we could use the Pivot’s SelectionChanged event here. But the arguments of the event are PivotItems – and knowing about UI controls is a big no-no for VIewModels.&lt;/p&gt;  &lt;p&gt;Well, Triggers to the rescue! By creating a simple trigger, and adding it to the PivotItem, we should be able to notify the ViewModel that it’s time to fill the ObservableCollection with data. Here is the code for the Trigger:&lt;/p&gt;  &lt;p&gt;&amp;#160;&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; PivotItemActivatedTrigger : TriggerBase&amp;lt;PivotItem&amp;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;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnAttached()&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;            AssociatedObject.Loaded += (o, eventArgs) =&amp;gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;                {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;                    var parentPivot = AssociatedObject.Parent &lt;span class="kwrd"&gt;as&lt;/span&gt; Pivot;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;&amp;#160;&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; (parentPivot == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;                        &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; InvalidOperationException(&lt;span class="str"&gt;&amp;quot;Parent of a PivotItem should be a Pivot&amp;quot;&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;                    parentPivot.SelectionChanged += (sender, args) =&amp;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;if&lt;/span&gt; (parentPivot.SelectedItem == AssociatedObject)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;                                InvokeActions(&lt;span class="kwrd"&gt;null&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;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;    }&lt;/pre&gt;
&lt;/div&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;The Action we are invoking can be anything. Since I want to notify the ViewModel, I am using the CallDatacontextMethodAction as described in my older article “&lt;a href="http://www.silverlightshow.net/items/A-Designer-friendly-Approach-to-MVVM-Part-I.aspx" target="_blank"&gt;A Designer-friendly Approach to MVVM&lt;/a&gt;”. &lt;/p&gt;

&lt;p&gt;After the Trigger is added to the project, this is how I am using it in Blend:&lt;/p&gt;

&lt;p&gt;First, I drop the CallDatacontextMethodAction on the historyPivotItem.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_2CF7836F.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_6CC169F4.png" width="391" height="338" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then click the New button for the TriggerType:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_1799CE07.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_6C5536FF.png" width="323" height="218" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select PivotItemActivatedTrigger in the dialog, then click OK:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_32D22708.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_2493AE18.png" width="324" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;







&lt;p&gt;Finally, enter the method name:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_24277B23.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_31F9C11E.png" width="327" height="79" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One word of advice though: the trigger actually fires in the middle of the Pivot’s animation. If what you are doing in the EnsureHistory method is longer than a dozen or so milliseconds, make sure you fire up a background thread to do it.&lt;/p&gt;

&lt;p&gt;Please let me know if you found this tip useful!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=5114" width="1" height="1"&gt;</description><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Silverlight.net/default.aspx">Silverlight.net</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Expression+Blend/default.aspx">Expression Blend</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category></item><item><title>Behaviors for accessing the Windows Phone 7 MarketPlace and getting feedback</title><link>http://dotneteers.net/blogs/vbandi/archive/2011/01/08/behaviors-for-accessing-the-windows-phone-7-marketplace-and-getting-feedback.aspx</link><pubDate>Fri, 07 Jan 2011 23:38:41 GMT</pubDate><guid isPermaLink="false">74e06254-0e07-4c08-8611-9f55b924f030:5094</guid><dc:creator>vbandi</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://dotneteers.net/blogs/vbandi/rsscomments.aspx?PostID=5094</wfw:commentRss><comments>http://dotneteers.net/blogs/vbandi/archive/2011/01/08/behaviors-for-accessing-the-windows-phone-7-marketplace-and-getting-feedback.aspx#comments</comments><description>&lt;p&gt;Encouraging the users of your WP7 app to rate or buy your application, view other apps by you or just send a feedback email can make or break an app. However, the MarketPlace API can be a little confusing, and takes a little time to figure out which method does what. You can’t even try and see for yourself, because most MarketPlace actions don’t work until you actually have the app published. &lt;/p&gt;  &lt;p&gt;In this blog post I am going to share the code we use in our &lt;a href="http://wp7applist.com/app/5013/SurfCube+3D+Browser"&gt;SurfCube 3D Browser&lt;/a&gt; for the above tasks. To be precise, I am sharing four Actions that can help you, and have passed the MarketPlace a few times.&lt;/p&gt;  &lt;p&gt;To use these behaviors, just add the attached source code or binary to your project, recompile, and use them as any other Action in Blend – drag and drop them on the FrameWorkElement you want to perform the action, and set the properties.&lt;/p&gt;  &lt;p&gt;Here is what the About screen of SurfCube 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_51ABFBEB.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_0A56A5F9.png" width="244" height="229" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;It is possible that invoking the MarketPlace or the email program can take a little time. Users get impatient, and click on the link again, causing an Exception saying that the app is already dectivated, can’t invoke Launchers. The solution is to make sure the links are only clicked once, by disabling the Action, so that a repeat invokation won’t crash your application. Note, that all four actions cause you application to Tombstone, so plan accordingly. &lt;/p&gt;  &lt;h2&gt;The MarketPlaceReviewAction&lt;/h2&gt;  &lt;p&gt;This Action is added to the “Rate this app” link, and has no parameters. It opens the MarketPlace showing your app and the rating interface.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;The MarketPlaceDetailsAction&lt;/h2&gt;  &lt;p&gt;This Action is not used in SurfCube – it opens the MarketPlace and shows the details of your app. The underlying MarketPlaceDetailTask API can show another item, but you would have to extend the Action to accept parameters.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;The MarketPlaceSearchAction&lt;/h2&gt;  &lt;p&gt;This action is used in the “Other apps from Kinabalu Innovation” link, and can really help cross-promoting your apps. Just set the SearchTerm property to your publisher name, and the other apps will be displayed. Here is my setup:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_352F0A0B.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_43015006.png" width="244" height="39" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;The SendEmailAction&lt;/h2&gt;  &lt;p&gt;The Send feedback link allows the user to send an email. Tapping it will bring up a new email, pre-filled with the To, Subject and Body properties. I just attached the SendEmailAction to the hyperlink, and I set the properties:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_69CF6646.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_7BABFA13.png" width="238" height="278" /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;At another point of the application, I am asking for feedback about the future TAB support in the browser. I am using the same SendEmailAction with different parameters there:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_025F0397.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left: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_292D19D7.png" width="244" height="93" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Users usually leave the subject of the email unchanged, so I immediately know when I got a feedback from the app. &lt;/p&gt;  &lt;h2&gt;&lt;/h2&gt;        &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://cid-f107151f293b6eb6.office.live.com/self.aspx/Public/MarketPlaceBehaviors.zip" target="_blank"&gt;You can download the sample application here&lt;/a&gt;. It contains the source code of the above mentioned behaviors and a little WP7 app using them. &lt;/p&gt;  &lt;p&gt;Well, that’s it. I hope you find these little Actions useful!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=5094" width="1" height="1"&gt;</description><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Expression+Blend/default.aspx">Expression Blend</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category></item><item><title>Being theme aware in Windows Phone 7 Silverlight apps</title><link>http://dotneteers.net/blogs/vbandi/archive/2010/09/14/being-theme-aware-in-windows-phone-7-silverlight-apps.aspx</link><pubDate>Tue, 14 Sep 2010 17:29:00 GMT</pubDate><guid isPermaLink="false">74e06254-0e07-4c08-8611-9f55b924f030:4650</guid><dc:creator>vbandi</dc:creator><slash:comments>12</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://dotneteers.net/blogs/vbandi/rsscomments.aspx?PostID=4650</wfw:commentRss><comments>http://dotneteers.net/blogs/vbandi/archive/2010/09/14/being-theme-aware-in-windows-phone-7-silverlight-apps.aspx#comments</comments><description>&lt;p&gt;Windows Phone 7 users can customize their phones by choosing between a dark and a light background, and tons of accent colors. The &lt;a target="_blank" href="http://download.microsoft.com/download/D/8/6/D869941E-455D-4882-A6B8-0DBCAA6AF2D4/UI%20Design%20and%20Interaction%20Guide%20for%20Windows%20Phone%207%20Series.pdf"&gt;Windows Phone 7&amp;nbsp; UI Design and Interaction Guide&lt;/a&gt; tells us, that it is good to be theme-aware. For example, if the user selects a light background with red accent color, the application should also display its content on a light background with a red accent color. &lt;/p&gt;
&lt;h2&gt;Built-in Controls&lt;/h2&gt;
&lt;p&gt;The built-in Silverlight colors do a good job of reflecting the phone theme out of the box. For example, the Slider control always uses the accent color as the fill color. Here is a slider in the default dark/blue theme:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_2C6C71F6.png"&gt;&lt;img height="78" width="244" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_5E641280.png" alt="image" border="0" title="image" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And here is the same slider in light/red theme:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_6C36587B.png"&gt;&lt;img height="91" width="244" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_3729C94B.png" alt="image" border="0" title="image" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Drawings, shapes&lt;/h2&gt;
&lt;p&gt;If you want to draw a shape (for example, a rectangle or an ellipse) in a theme-aware manner, you can invoke some built-in resources. This ellipse will always have the accent color as its fill color:&lt;/p&gt;
&lt;p&gt;&amp;lt;Ellipse Stroke=&amp;quot;Black&amp;quot;&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Ellipse.Fill&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;SolidColorBrush Color=&amp;quot;{StaticResource PhoneAccentColor}&amp;quot;/&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Ellipse.Fill&amp;gt; &lt;br /&gt;&amp;lt;/Ellipse&amp;gt;&lt;/p&gt;
&lt;p&gt;Here is the ellipse in the default theme:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_44FC0F46.png"&gt;&lt;img height="244" width="166" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_3DDCD2CE.png" alt="image" border="0" title="image" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And here it is in the light/red theme:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_4FB9669B.png"&gt;&lt;img height="244" width="181" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_76877CDB.png" alt="image" border="0" title="image" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can use similar resource binding techniques in your own controls to make them theme-aware. There are tons of color resources defined, you can see them in Expression Blend:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_4B42E5D4.png"&gt;&lt;img height="151" width="244" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_5D1F79A1.png" alt="image" border="0" title="image" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;&lt;/h2&gt;
&lt;h2&gt;Being theme-aware in code&lt;/h2&gt;
&lt;p&gt;Sometimes, you cannot just bind to resources, you need to actually use the colors in your code. For example, you may need to draw something on a WriteableBitmap, using the accent color. The same resource can be used from code like this:&lt;/p&gt;
&lt;pre&gt;Color accent = (Color)Resources[&amp;quot;PhoneAccentColor&amp;quot;];&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;To draw a pixel on the WriteableBitmap with this color, you need to access the WriteableBitmap&amp;rsquo;s Pixels array (more information &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap.pixels(v=VS.95).aspx"&gt;here&lt;/a&gt;), and set one of its items to an integer value. The following code shows how you can calculate the value based on the accent color acquired before:&lt;/p&gt;
&lt;pre&gt;uint accentColor = (uint)accent.A * 0x1000000 + &lt;br /&gt;                   (uint)accent.R * 0x10000 + &lt;br /&gt;                   (uint)accent.G * 0x100 +&lt;br /&gt;                   (uint)accent.B;&lt;/pre&gt;
&lt;p&gt;Now, to set the upper left corner of the WriteableBitmap to this color, all you have to do is:&lt;/p&gt;
&lt;pre&gt;myWriteableBitmap.Pixels[0] = (int)accentColor;&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;Small step for a little colored pixel, but a giant leap for Theme Consistency!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=4650" width="1" height="1"&gt;</description><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/User+Experience/default.aspx">User Experience</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Expression+Blend/default.aspx">Expression Blend</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category></item><item><title>Designing the Windows Phone 7 “Mix Zoomery” app</title><link>http://dotneteers.net/blogs/vbandi/archive/2010/07/11/designing-the-windows-phone-7-mix-zoomery-app.aspx</link><pubDate>Sun, 11 Jul 2010 21:26:26 GMT</pubDate><guid isPermaLink="false">74e06254-0e07-4c08-8611-9f55b924f030:4321</guid><dc:creator>vbandi</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://dotneteers.net/blogs/vbandi/rsscomments.aspx?PostID=4321</wfw:commentRss><comments>http://dotneteers.net/blogs/vbandi/archive/2010/07/11/designing-the-windows-phone-7-mix-zoomery-app.aspx#comments</comments><description>&lt;p&gt;&lt;em&gt;Summary: this blog post details the design decisions and some technical information behind the Windows Phone 7 Mix Zoomery app.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;Some of you may have heard of Zoomery, which is the Deep Zoom framework of my company (&lt;a href="http://www.response.hu"&gt;Response&lt;/a&gt;). Some of you may have even seen our &lt;a href="http://mix.zoomery.com"&gt;Mix Zoomery demo&lt;/a&gt;, which allows browsing of all 130 presentations and 3271 slides of the Mix’10 conference. 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_63D54C14.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" class="wlDisabledImage" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_21EE66C6.png" width="421" height="258" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Ever since I have heard that Windows Phone 7 would include deep zoom I wanted to see how Zoomery worked with it. So, what better way to find out than to port one of our latest samples over to the phone?&lt;/p&gt;  &lt;p&gt;Armed with the WP7 SDK, I started to make it happen. It was fairly difficult to find some free time to work on the project, but at the end, after about 2 days of net working (which took me weeks to do &lt;img style="border-bottom-style:none;border-right-style:none;border-top-style:none;border-left-style:none;" class="wlEmoticon wlEmoticon-sadsmile" alt="Sad smile" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/wlEmoticonsadsmile_5F00_756536DF.png" /&gt;), I was finally satisfied with the result enough to create a quick screen capture video, upload it to YouTube, and tweet about it.&lt;/p&gt;  &lt;p&gt;Here is the video:&lt;/p&gt;  &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:146ba739-e301-4647-a594-8b8439bf9b3e" class="wlWriterEditableSmartContent"&gt;&lt;div&gt;&lt;object width="425" height="355"&gt;&lt;param name="movie" value="http://www.youtube.com/v/CgW-p0PxdtQ&amp;amp;hl=en"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/CgW-p0PxdtQ&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 style="width:425px;clear:both;font-size:.8em;"&gt;WP7 Mix Zoomery App video&lt;/div&gt;&lt;/div&gt; &lt;/p&gt;  &lt;br /&gt;    &lt;p&gt;&lt;em&gt;Shameless plug: the reaction was overwhelmingly positive. Until now, the video has been seen almost 2000 times. More than 20 peeps tweeted about it (excluding me&lt;img style="border-bottom-style:none;border-right-style:none;border-top-style:none;border-left-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/wlEmoticonsmile_5F00_0741CAAD.png" /&gt;, but including WP7 demigod Charlie Kindel). There are two English articles (WMPowerUser.com came up with the title “&lt;/em&gt;&lt;a href="http://wmpoweruser.com/zoomery-com-mixes-up-deepzoom/?utm_source=feedburner&amp;amp;utm_medium=feed&amp;amp;utm_campaign=Feed%3A+WmPowerUser+%28WM+Power+User%29"&gt;&lt;em&gt;Zoomery.com MIXes up Deepzoom&lt;/em&gt;&lt;/a&gt;&lt;em&gt;” and MobiletechWorld’s article “&lt;/em&gt;&lt;a href="http://www.mobiletechworld.com/2010/07/05/browse-all-the-mix-2010-presentations-with-deepzoom-on-windows-phone-7/"&gt;&lt;em&gt;Browse all the MIX 2010 presentations with Deepzoom on Windows Phone 7&lt;/em&gt;&lt;/a&gt;&lt;em&gt;”), one &lt;/em&gt;&lt;a href="http://pda.pl/news/czy_da_sie_plynnie_przejrzec_1_2_gigapikseolowe_zdjecie_pod_windows_phone_7/"&gt;&lt;em&gt;Polish article&lt;/em&gt;&lt;/a&gt;&lt;em&gt;, and a Chinese one &lt;/em&gt;&lt;a href="http://translate.google.com/translate?hl=en&amp;amp;sl=zh-CN&amp;amp;u=http://wm.sj.91.com/content/2010-07-04/20100704222103106.shtml&amp;amp;ei=7fI5TL_1GZG7jAfrktj_Aw&amp;amp;sa=X&amp;amp;oi=translate&amp;amp;ct=result&amp;amp;resnum=6&amp;amp;ved=0CEYQ7gEwBTgK&amp;amp;prev=/search%3Fq%3Dzoomery%26start%3D10%26hl%3Den%26safe%3Doff%26sa%3DN%26tbo%3D1%26rls%3Dcom.microsoft:en-us%26tbs%3Dqdr:w"&gt;&lt;em&gt;here&lt;/em&gt;&lt;/a&gt;&lt;em&gt; (translated). &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;So, I’ve decided to ride the wave, and write about how the app came to be – that is what this blog post is about.&lt;/p&gt;  &lt;h1&gt;&lt;/h1&gt;  &lt;h1&gt;Technical details&lt;/h1&gt;  &lt;p&gt;Heard the saying “If you are a Silverlight developer, you are already a Windows Phone 7 developer”? Well, it is true. In fact, it is so much true, there is not a lot I can write about the technical side. That is why this post is called “Designing the WP7 Mix Zoomery app” – most work went into the design, not the implementation.&lt;/p&gt;  &lt;p&gt;For example, I could easily reuse the deep zoom tile set I have created earlier for the web version of the application. The WP7 app uses the same tiles, from the same server, with the same metadata. What is more, I could reuse the entire “DeepZoomHelper” class that we have been developing for years – it handles the panning and zooming, the filtering, sorting, metadata handling within the Zoomery framework. I created a new WP7 Silverlight class library project, linked in the files from the web version, and it worked. I did add some &amp;quot;#ifdef&amp;#160; WP7” though to get rid of things like the floating zooming toolbar that is created for notebook users without a mouse wheel:&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" class="wlDisabledImage" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_191E5E7A.png" width="147" height="150" /&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;I also disabled the automatic refreshing of the property for the “currently centered” item during panning, because we don’t need it in the WP7 version, and it does tax the weaker mobile CPU somewhat. (On the desktop version, there is an event that fires every time the centered item is changed, to allow showing the info panel). I could also reuse the metadata-parsing logic for the details page.&lt;/p&gt;  &lt;p&gt;So, if I could reuse the server side Deep Zoom generator, and the client side&amp;#160; DeepZoomHelper library, what did I have to do? &lt;/p&gt;  &lt;h1&gt;Designing the UX&lt;/h1&gt;  &lt;p&gt;The majority of the work was adopting to the different form factor and interaction mechanisms of the phone. It goes without saying, that the phone is not just a small PC. I had to start thinking about the user experience from scratch.&lt;/p&gt;  &lt;p&gt;I wanted to transfer as much of the feature set and experience of the original application, as possible. So, here is what I wanted the app to do:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;View all presentations, grouped by key topics&lt;/li&gt;    &lt;li&gt;Navigate by zooming and panning&lt;/li&gt;    &lt;li&gt;Filter the presentations by any word in the title, tags, presenter or abstract&lt;/li&gt;    &lt;li&gt;Review detailed info on every presentation&lt;/li&gt;    &lt;li&gt;Navigate to related presentations (by tags or presenters)&lt;/li&gt;    &lt;li&gt;Watch the streaming video of any presentation in high or lower qualities&lt;/li&gt;    &lt;li&gt;I decided not to have the “front row view” functionality at this time – it will be fun to tie some perspective transforms to an accelerometer, but this is not something that I wanted to venture into without a real device.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;As for the UX, I wanted to fit the app to the nice Metro UX as much as possible. This means that content is king - there are no fancy adorners, animations and typography are where the wow factor should live. Metro is also an authentically digital experience – a Metro app does not want to look like a real-world device. A true WP7 app also honors the WP7 way of navigation: namely, the back button, which should always take you back to the previous screen. I also wanted the app to honor both landscape and portrait mode.&lt;/p&gt;  &lt;p&gt;Let’s see how the above challenges were tackled!&lt;/p&gt;  &lt;h2&gt;&lt;/h2&gt;    &lt;h2&gt;View all presentations, grouped by key topics&lt;/h2&gt;  &lt;p&gt;This was the easiest. The abovementioned DeepZoomHelper library and the zoom tile set I created earlier for the web app just worked, out of the box. Luckily, as the main topic of the Mix10 conference was Windows Phone 7, I already had the presentations rendered in a nice, Metro-like way, and using the Segoe font, so there was nothing to do here.&lt;/p&gt;  &lt;h2&gt;&lt;/h2&gt;  &lt;h2&gt;Navigate by zooming and panning&lt;/h2&gt;  &lt;p&gt;This one was more tricky. Obviously, the best way to do zooming on a phone is to use two finger gestures. Unfortunately, I don’t have a phone, nor a multitouch monitor, so I was not able to test this approach. Instead, I opted for a Zoom in and Zoom out button in the Application Bar (the separate area on the bottom of the WP7 screen). Clicking on the buttons calls the same zoom methods in our helper library as the mouse wheel does in the web version. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_1FD167FD.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;margin:0px;display:inline;border-top:0px;border-right:0px;" class="wlDisabledImage" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_44EEB269.png" width="228" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;After playing with it for a while, I left these buttons in – even if I have the pinch gesture implemented, these buttons would work well for one handed usage (when you don’t have another hand available to hold the phone or you can’t put it down on a table and use two fingers). The buttons also help discoverability – even if a novice user does not think of trying the pinch gestures, he will certainly press the buttons on the bottom to figure out what the app does.&lt;/p&gt;  &lt;p&gt;Panning is also important – fortunately, I didn’t have to do anything to make it work. The DeepZoomHelper already was listening to the mouse events, and single touch gestures are nicely translated to mouse events. Nice!&lt;/p&gt;  &lt;h2&gt;Filtering&lt;/h2&gt;  &lt;p&gt;The web version of the app can filter the presentations by any word that is in the title, tags, presenter or the abstract of the presentation. You may notice, that as soon as the filtering takes place, the categorized view disappears, and you have a different, filtered view:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_36B03979.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;margin:0px;display:inline;border-top:0px;border-right:0px;" class="wlDisabledImage" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_6BACA2DC.png" width="244" height="166" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The WP7 app behaves exactly the same way. It filters after every character entered – but if this turns out to be too slow on a real device (it is slow on the emulator), it can easily be changed to perform filtering after the entire filter phrase has been entered.&lt;/p&gt;  &lt;p&gt;On the web app, the filter textbox is always visible. However, I didn’t want to waste precious reading / browsing space on the WP7 screen, so I decided to hide the Filter UI, and only show it when the user specifically requests it by pressing the magnifying glass icon in the Application Bar. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_35C7ADC2.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;margin:0px;display:inline;border-top:0px;border-right:0px;" class="wlDisabledImage" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_619801B1.png" width="126" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The filter UI consists of a text entry field, and a clear filter button. The later does not exist in the web version, because it is too fun to see presentations come back as you remove characters one by one from the filter. However, on the phone, typing is much more painful, so I decided to add the clear button there. &lt;/p&gt;  &lt;p&gt;A part of the filter UI is the software keyboard that shows up when the focus is in the textbox. This means that there is not much space left to watch the presentations come and go as you type or delete characters. (I guess this is one more reason to have the filtering only happen after Enter is pressed…) I am using the “Search” &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.input.inputscopenamevalue(VS.95).aspx"&gt;input scope&lt;/a&gt; for the TextBox. This replaces the Enter key with the right arrow key on the keyboard, and indicates the user that by pressing it, they are going to go to another place in the application.&lt;/p&gt;    &lt;p&gt;On the technical side, the search UI is implemented as a separate Visual State Group, and show / hide animations are defined as state transitions:&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" class="wlDisabledImage" title="image" border="0" alt="image" align="left" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_6C555906.png" width="385" height="92" /&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;/p&gt;    &lt;br /&gt;    &lt;br /&gt;    &lt;p&gt;There is a 0.6 second transition with Cubic easing, for a nice appear / disappear effect (did I mention that I love easings?).&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Note: It would be great to use the hardware search button instead of putting it on the Application Bar. Unfortunately, it seems like WP7 won’t allow 3rd party apps to override the behavior of the physical Search button (at least in V1). This is very unfortunate – the physical Search button acts as one would expect it to act in the OS itself – it allows for contact search while viewing the contact list, for example. Not allowing similar behavior for third party apps makes these apps less discoverable, and increases user frustration, when pressing the button takes them out of the currently running app all the way to Bing. Of course, they can always press the back button, but still, this is a frustrating experience! To make things worse, by the time the search button will be overridable by apps in V1.1 or V2 or whenever, users will be trained not to experiment with it. Please, Microsoft, if you can add just one thing until release, make it the overridable search button! Don’t let our users be trained to ignore it!&lt;/em&gt;&lt;/p&gt;  &lt;h2&gt;Details info&lt;/h2&gt;  &lt;p&gt;Perhaps the biggest difference between the UX of the web and the WP7 app is how the presentation details are shown. On the web, whenever a presentation fills in a big enough part of the screen, a panel comes in on the right, and shows the information, . On the WP7 app, we don’t have the luxury to sacrifice so many pixels. So, I have added another button to the App Bar, which shows the information for the currently centered presentation. I was considering using an information icon (a lowercase i in a circle) for this, but decided that users would mistake it for an about-like menu item, and would miss the gateway to the most useful part of the application – the presentation details and the video features. Therefore I opted for the more interesting right arrow, hoping that users would get the “proceed” meaning. &lt;/p&gt;  &lt;p&gt;I admit, there is some room for improvement here. The discoverability of this feature is not good – the arrow is unchanged from the moment the application starts, and while all the zooming and panning action is going on on the screen, the little arrow at the bottom is forgotten. The solution would be to only show the arrow when there is an active presentation to show the details of, or even add some attention-grabbing animation to the “proceed to the details” button. The developer is supposed to be able to enable / disable / hide the App Bar buttons, but these features are not working in the current bits. Before I can decide on how to make this part right, I will need to see the app on a real device (to see how much more I can put on the CPU), and also, I will have to see if there are any animations for enabling a button or make it visible. &lt;/p&gt;  &lt;p&gt;So, what happens if the user does press the “Proceed to details” button? Well, he / she is taken to the next screen, where – surprise – the details of the centered presentation are displayed:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_2C1F3F8C.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;margin:0px;display:inline;border-top:0px;border-right:0px;" class="wlDisabledImage" title="image" border="0" alt="image" src="http://dotneteers.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vbandi/image_5F00_thumb_5F00_196A45D5.png" width="199" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This is a no-nonsense, text-only screen. The title of the session is displayed on top, followed by the presenters, links to the videos, the abstract, tags and finally, a link to the mix website. The blue text is active (it is actually displayed using the active system color, so if the user prefers red or green, this screen would show the active text in red or green).&lt;/p&gt;  &lt;p&gt;Clicking on a presenter or a tag takes the user back to the main deep zoom screen, filtered by the specific presenter or tags. This allows for a quick way to find related presentations. However, clicking on a video link launches the default video player of the WP7 OS, with either the high or the normal bandwidth video from the Mix website. &lt;/p&gt;  &lt;p&gt;The details screen is implemented as another visual state in the app. The transition between the main and the details view looks like the the default rotation transition on the phone to keep it consistent with the underlying OS. By default, the details view has a perspective transform applied to the Y axis of –105 degrees. When the details view is activated, the main view is rotated by 90 degrees along the Y axis, and the details view is rotated to 0 degrees, thus occupying the phone’s screen. This trick works well when there are only a few statuses that need to be switched. Using Blend’s transition preview functionality, it is fairly easy to finetune this animation without launching the app.&lt;/p&gt;  &lt;p&gt;To navigate back to the main deepzoom view, the user only has to press the physical Back button. By default, the back button would go back to the start screen (or wherever the app was launched from). The &lt;a href="http://go.microsoft.com/?linkid=9713252"&gt;WP7 UI Guidelines&lt;/a&gt; allow the back button to be overridden, if we are using it to dismiss a dialog or navigate within the application to a previous view. That is exactly what is happening here. Not at all coincidentally, when the user presses the back button while playing a video (or viewing a presentation’s link), they get back to the WP7 Mix Zoomery application via a very similar animation. This consistency makes the WP7 media player look like it is part of the app, and thus I did not need to implement video playback like I had to do in the web version.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Note: I love the WP7 Back button. Just think of how often you use the Back button in the browser – the physical back button on the phone has the same role. This is an area where the WP7 OS has an advantage to the iPhone, where every app has to have its own back mechanism, often putting the back button on different places. On WP7, the back button has to be the leftmost button below the screen, which is the most convenient place for your thumb if you are holding the phone in your right hand, but also very easy to reach when the phone is in the left hand. I know that the Android OS also requires the presence of a physical back button, but it still does not specify where the button should be according to &lt;/em&gt;&lt;a href="http://gdgt.com/discuss/everyone-complains-about-androids-fragmentation-os-level-98h/"&gt;&lt;em&gt;this post&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;  &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;The greatest challenge in porting an application from the web / desktop version of Silverlight to WP7 is that the latter demands a totally different approach to the user experience. You can expect an almost complete rewrite here, but almost none, when it comes to the business logic, client-server communication, models, server side, etc. However, the existing Silverlight development skillset you or your team has is almost 100% percent transferable – the new concepts (such as the Application Bar, the gestures, the sensors, etc.) are easy to grasp. In my opinion Microsoft made the right bet choosing Silverlight as one of the two development platforms for Windows Phone 7, making over 500,000 Silverlight developers WP7 developers overnight.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://dotneteers.net/aggbug.aspx?PostID=4321" width="1" height="1"&gt;</description><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/User+Experience/default.aspx">User Experience</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/UX+Thoughts/default.aspx">UX Thoughts</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Silverlight.net/default.aspx">Silverlight.net</category><category domain="http://dotneteers.net/blogs/vbandi/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category></item></channel></rss>