<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.microsoft.co.il/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>Arik Poznanski&amp;#39;s Blog : Windows Phone 7</title><link>http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+Phone+7/default.aspx</link><description>Tags: Windows Phone 7</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>Using Windows Phone As Windows 7 Accelerometer Sensor</title><link>http://blogs.microsoft.co.il/blogs/arik/archive/2011/08/13/using_2D00_windows_2D00_phone_2D00_as_2D00_windows_2D00_7_2D00_accelerometer_2D00_sensor.aspx</link><pubDate>Sat, 13 Aug 2011 15:54:20 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:883702</guid><dc:creator>arik</dc:creator><slash:comments>191</slash:comments><description>&lt;p&gt;I just had a cool idea! (actually I had it like 6 month ago, but bear with me).&lt;/p&gt;  &lt;p&gt;My idea involves mixing some of the features in Windows 7 with some of the features in Windows Phone 7, to create a glorious mix!&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/image_6105F6E1.png"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="image" alt="image" src="http://blogs.microsoft.co.il/blogs/arik/image_thumb_25DE2CE4.png" width="640" height="382" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Windows 7&lt;/h3&gt;  &lt;p&gt;One of the new features in Windows 7 is the &lt;a href="http://msdn.microsoft.com/en-us/library/dd318953(VS.85).aspx"&gt;Sensor API&lt;/a&gt; which provides a standard interface for accessing sensors of various types, like &lt;font style="background-color:#ffff00;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;accelerometer&lt;/strong&gt;&lt;font style="background-color:#ffff00;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;, etc..&lt;/p&gt;  &lt;p&gt;I &lt;a href="http://blogs.microsoft.co.il/blogs/arik/archive/2010/06/29/using-windows-7-light-sensor-in-your-application.aspx"&gt;wrote&lt;/a&gt; in the past about how you can consume this API from a C# application using &lt;a href="http://code.msdn.microsoft.com/WindowsAPICodePack"&gt;Windows API Code Pack&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Windows Phone 7&lt;/h3&gt;  &lt;p&gt;Windows Phone 7 comes with a few sensors out of the box, among them: &lt;strong&gt;&lt;font style="background-color:#ffff00;"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;strong&gt;accelerometer!&lt;/strong&gt;&lt;strong&gt;&lt;font style="background-color:#ffff00;"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Idea&lt;/h3&gt;  &lt;p&gt;What if we use Windows Phone 7 accelerometer sensor as a standard device on Windows 7?&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Roadmap&lt;/h3&gt;  &lt;p&gt;So how can we accomplish that? let&amp;#39;s break the idea to steps:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Step 1&lt;/u&gt;: Create a software driver &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I’ll start with creating a dummy software driver. This driver will implement what&amp;#39;s necessary to be a standard Windows 7 Accelerometer sensor, but at this stage will simply return constant data.&lt;/p&gt;  &lt;p&gt;In order to write a sensor driver for Windows 7 I’ll need to use &lt;a href="http://www.microsoft.com/whdc/driver/wdf/umdf.mspx"&gt;User Mode Driver Framework&lt;/a&gt; (UMDF), a COM-like, C++ framework for writing user-mode drivers in Windows 7.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Step 2&lt;/u&gt;: Transfer Windows Phone 7 sensor data into the PC&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The next step is to find a way to transfer the accelerometer data from a Windows Phone device into the PC. One possible way of doing this implementing a local WCF service on the desktop that the Phone will keep calling with accelerometer data. This will require an application to run on the phone to keep the data flowing.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Step 3&lt;/u&gt;: Consume the WCF service from the phone&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Using the service from the previous step we can now consume it in a simple Windows Phone application that all it does is getting the accelerometer sensor data using the phone API and call the WCF service with the latest data.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Step 4&lt;/u&gt;: Make the software driver consume the Windows Phone 7 data&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Now that I have a software driver that returns dummy accelerometer data and a way to get real accelerometer data from the Windows Phone, all I need to do is connecting the dots and make my accelerometer driver return the real data. To do this I&amp;#39;ll need some kind of inter process communication to transfer the data from the WCF service to the driver.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Long Story Short…&lt;/h3&gt;  &lt;p&gt;I present to you the &lt;strong&gt;Windows Phone Accelerometer Driver for Windows 7&lt;/strong&gt;!&lt;/p&gt;  &lt;p&gt;The full source code for this project can be found on the &lt;font style="background-color:#ffff00;"&gt;&lt;/font&gt;&lt;a href="http://wp7accelerometer.codeplex.com/"&gt;CodePlex project site&lt;/a&gt;&lt;font style="background-color:#ffff00;"&gt;&lt;/font&gt;.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Some Implementation Details&lt;/h3&gt;  &lt;p&gt;The actual driver was fairly easy to implement since I used the CodeProject article &amp;quot;&lt;a href="http://www.codeproject.com/KB/system/wiisensor.aspx"&gt;Writing a Sensor Driver for the Wiimote on Windows 7&lt;/a&gt;&amp;quot; by &lt;a href="http://blogorama.nerdworks.in/entry-WritingasensordriverfortheWiim.aspx"&gt;Rajasekharan Vengalil&lt;/a&gt; as a base for my Windows Phone 7 driver. You can find the driver source code in the project named &lt;strong&gt;WP7AccelerometerDriver&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;As mentioned earlier I&amp;#39;ve implemented a simple local WCF service for transferring the accelerometer data from the phone to the driver. You can find the service source code in the project named &lt;strong&gt;WP7AccelerometerService&lt;/strong&gt;. The service uses named pipes to communicate with the driver.&lt;/p&gt;  &lt;p&gt;The phone application is a very simple one that consumes the WCF service and call it whenever a new accelerometer value is available. You can find its source code in the project named &lt;strong&gt;WP7AccelerometerClient&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;Finally, if you want to check the functionality of the accelerometer driver you can use either the &lt;strong&gt;SensorDiagnostics &lt;/strong&gt;project or the more fun &lt;strong&gt;PlaneDemo&lt;/strong&gt; project, which I borrowed for &lt;a href="http://weblogs.asp.net/sergeyzwezdin/archive/2009/07/01/windows-7-sensor-and-location-platform-sensors-programming-part-2-3.aspx"&gt;Sergey Zwezdin blog&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;How to Install?&lt;/h3&gt;  &lt;p&gt;1. Download and extract project binaries or source from the &lt;a href="http://wp7accelerometer.codeplex.com/releases/view/71672"&gt;CodePlex project site&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;2. Open &lt;strong&gt;CMD&lt;/strong&gt; &lt;u&gt;as administrator &lt;/u&gt;&lt;/p&gt;  &lt;p&gt;3. Go to the folder &lt;strong&gt;\Driver\Install\&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;4. According to the bitness of your OS Run &lt;strong&gt;install_wp7_driver_32bit.bat &lt;/strong&gt;or &lt;strong&gt;install_wp7_driver_64bit.bat&lt;/strong&gt; to install the driver. &lt;a href="http://blogs.microsoft.co.il/blogs/arik/image_25322462.png"&gt;     &lt;br /&gt;      &lt;br /&gt;&lt;/a&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/image_25322462.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/arik/image_thumb_71799236.png" width="600" height="490" /&gt;&lt;/a&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;5. When the following notification appears, select &amp;quot;&lt;strong&gt;Install this driver software anyway&lt;/strong&gt;&amp;quot;: &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/image11_1F04C4AD.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/arik/image11_thumb_250BC5AE.png" width="600" height="344" /&gt;&lt;/a&gt;     &lt;br /&gt;This should take around 1-2 minutes to complete. &lt;/p&gt;  &lt;p&gt;6. Enable installed Sensor in the &lt;strong&gt;Control Panel&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/image_5B6F12A5.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/arik/image_thumb_18336EAB.png" width="600" height="374" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;7. Run the WCF service from &lt;u&gt;as administrator&lt;/u&gt;. If you run it from Visual Studio, make sure you ran Visual Studio as administrator.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/image_7191B5D2.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/arik/image_thumb_7B963130.png" width="600" height="135" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;8. Run the Windows Phone client on a real device while connected to the PC and enter your PC (LAN) IP &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/image_574126E1.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/arik/image_thumb_23F4C7AB.png" width="330" height="600" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;9. That&amp;#39;s it! you can now sit back and enjoy the ride using the &lt;strong&gt;PlaneDemo&lt;/strong&gt; application or &lt;strong&gt;SensorDiagnostics&lt;/strong&gt;, or any other software that uses the accelerometer sensor. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/image_0DAE868C.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/arik/image_thumb_7E8781E4.png" width="500" height="600" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/image_6EF44A48.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/arik/image_thumb_05C2F5F8.png" width="600" height="400" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;How to Uninstall? &lt;/h3&gt;  &lt;p&gt;If you want to uninstall the driver simply go to the &lt;strong&gt;Device Manager&lt;/strong&gt;, select the &amp;quot;&lt;strong&gt;WP7 Accelerometer Sensor&lt;/strong&gt;&amp;quot; device from the &lt;strong&gt;Sensors &lt;/strong&gt;category, select uninstall from the context menu and &lt;strong&gt;make sure you mark the checkbox to delete the driver&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/image_32C7BCF9.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/arik/image_thumb_1B005FC6.png" width="466" height="287" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Final Note&lt;/h3&gt;  &lt;p&gt;I&amp;#39;ve seen the project works both on a real device and using the phone emulator, however it&amp;#39;s not a one-click install. I expect users to have problems with the installation. If you encounter some problems, please post on the &lt;font style="background-color:#ffff00;"&gt;&lt;/font&gt;&lt;a href="http://wp7accelerometer.codeplex.com/discussions"&gt;CodePlex project site forum&lt;/a&gt;&lt;font style="background-color:#ffff00;"&gt;&lt;/font&gt; page and I&amp;#39;ll do my best to help. &lt;/p&gt;  &lt;p&gt;Also, if you want to improve the source code (maybe adding GPS support?) or the installation procedure, I&amp;#39;ll be happy to include your improvements and even include you as one of the project members on CodePlex.&lt;/p&gt;  &lt;p&gt;This project was pure fun since it combines many useful technologies to create real value. Among the technologies you can find: C++, COM, UMDF, C#, WCF, WP7, etc..&lt;/p&gt;  &lt;p&gt;That&amp;#39;s it for now,    &lt;br /&gt;Arik Poznanski.&lt;/p&gt;&lt;div class="wlWriterHeaderFooter" style="margin:0px;padding:0px 0px 0px 0px;"&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/08/13/using_2D00_windows_2D00_phone_2D00_as_2D00_windows_2D00_7_2D00_accelerometer_2D00_sensor.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/08/13/using_2D00_windows_2D00_phone_2D00_as_2D00_windows_2D00_7_2D00_accelerometer_2D00_sensor.aspx&amp;amp;bgcolor=6600FF" /&gt;&lt;/a&gt; &lt;a href="http://dotnetshoutout.com/Submit?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/08/13/using_2D00_windows_2D00_phone_2D00_as_2D00_windows_2D00_7_2D00_accelerometer_2D00_sensor.aspx"&gt;&lt;img alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/08/13/using_2D00_windows_2D00_phone_2D00_as_2D00_windows_2D00_7_2D00_accelerometer_2D00_sensor.aspx" style="border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=172641" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt; &lt;/div&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=883702" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/COM/default.aspx">COM</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/CodePlex/default.aspx">CodePlex</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/C_2B002B00_/default.aspx">C++</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Accelerometer/default.aspx">Accelerometer</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/UMDF/default.aspx">UMDF</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Driver/default.aspx">Driver</category></item><item><title>Windows Phone Tutorial Published [HEB]</title><link>http://blogs.microsoft.co.il/blogs/arik/archive/2011/08/04/windows.phone.tutorial.published.hebrew.aspx</link><pubDate>Thu, 04 Aug 2011 21:09:31 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:879842</guid><dc:creator>arik</dc:creator><slash:comments>9</slash:comments><description>&lt;p&gt;I&amp;#39;ve recently published a 41 chapters tutorial in Hebrew about developing application using Windows Phone. The tutorial is hosted on the great Hebrew developers community site: &lt;a href="http://webmaster.org.il/"&gt;WebMaster.org.il&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/logo_windows_phone_v_51163FE8.jpg"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="Windows Phone Tutorial Published [HEB]" border="0" alt="Windows Phone Tutorial Published [HEB]" src="http://blogs.microsoft.co.il/blogs/arik/logo_windows_phone_v_thumb_35C3C170.jpg" width="377" height="323" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The tutorial is based on &lt;strong&gt;Windows Phone Mango &lt;/strong&gt;and it teaches Windows Phone development from the first step, using &lt;strong&gt;Visual Studio 2010 Express&lt;/strong&gt;, provided freely by Microsoft.&lt;/p&gt;  &lt;p&gt;&lt;img style="display:block;float:none;margin-left:auto;margin-right:auto;" title="Windows Phone Tutorial Published [HEB]" alt="Windows Phone Tutorial Published [HEB]" src="http://webmaster.org.il/data/upl/articles2/-Windows-Phone-----_81C5/image601_3.png" /&gt;&lt;/p&gt;  &lt;p&gt;Following is the index for all chapters:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone"&gt;Introduction &amp;amp; Working Environment&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-first-application"&gt;First Application&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-xaml"&gt;XAML Language&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-properties"&gt;Setting Properties in XAML&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-code-behind"&gt;XAML and Code-behind C#&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-layout"&gt;Layout: Introduction&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-layout-stackpanel"&gt;Layout: Using StackPanel&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-layout-grid"&gt;Layout: Using Grid&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-layout-canvas"&gt;Layout: Using Canvas&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-layout-properties"&gt;Layout: Additional Properties&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-basic-controls"&gt;Basic Controls: Introduction&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-basic-controls-buttons"&gt;Basic Controls: Button Controls&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-basic-controls-text"&gt;Basic Controls: Text Controls&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-basic-controls-listbox"&gt;Basic Controls: ListBox&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-border-slider-progressbar"&gt;More Controls&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-web-controls"&gt;Web Controls&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-content-control"&gt;Understanding ContentControl&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-dependency-properties"&gt;Using Dependency Properties&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-routed-events"&gt;Using Routed Events&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-adding-pages"&gt;Adding Pages to the Application&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-resources"&gt;Using Resources&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-data-binding"&gt;Data Binding: Introduction&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-data-binding-mode"&gt;Data Binding: Controlling Information Flow&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-data-binding-update-source-trigger"&gt;Data Binding: Controlling Update Time&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-data-binding-sources"&gt;Data Binding: Defining Source&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-data-binding-ivalueconverter"&gt;Data Binding: Using IValueConverter&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-data-binding-inotifypropertychanged"&gt;Data Binding: Using INotifyPropertyChange&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-data-binding-collection"&gt;Data Binding: Binding to Collections&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-data-templates"&gt;Using Data Templates&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-shapes"&gt;Using Shapes&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-brushes"&gt;Using Brushes&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-image-and-video"&gt;Displaying Images and Videos&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-transformations"&gt;Using Transformations&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-styles"&gt;Using Styles&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-pivot-panorama"&gt;Using Pivot and Panorama&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-orientation"&gt;Handle Phone Orientation&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-application-bar"&gt;Working with Application Bar&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-lifecycle"&gt;Application Lifecycle&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-launchers"&gt;Using Launchers&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-choosers"&gt;Using Choosers&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://webmaster.org.il/articles/windows-phone-sensors-accelerometer"&gt;Using Accelerometer Sensor&lt;/a&gt; &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Coming next: A Silverlight guide and a WPF guide (with technology specific details and screenshots).&lt;/p&gt;  &lt;p&gt;That&amp;#39;s it for now,    &lt;br /&gt;Arik Poznanski.&lt;/p&gt;&lt;div class="wlWriterHeaderFooter" style="margin:0px;padding:0px 0px 0px 0px;"&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/08/04/windows.phone.tutorial.published.hebrew.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/08/04/windows.phone.tutorial.published.hebrew.aspx&amp;amp;bgcolor=6600FF" /&gt;&lt;/a&gt; &lt;a href="http://dotnetshoutout.com/Submit?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/08/04/windows.phone.tutorial.published.hebrew.aspx"&gt;&lt;img alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/08/04/windows.phone.tutorial.published.hebrew.aspx" style="border:0px;" /&gt;&lt;/a&gt; &lt;/div&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=879842" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/webmaster.org.il/default.aspx">webmaster.org.il</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Hebrew/default.aspx">Hebrew</category></item><item><title>Sela Developer Days 2011 – Save the Date!</title><link>http://blogs.microsoft.co.il/blogs/arik/archive/2011/05/20/sela-developer-days-2011-save-the-date.aspx</link><pubDate>Fri, 20 May 2011 18:04:28 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:836636</guid><dc:creator>arik</dc:creator><slash:comments>1</slash:comments><description>&lt;div class="wlWriterHeaderFooter" style="float:none;margin:0px;padding:4px 0px 4px 0px;"&gt;&lt;iframe src="http://www.facebook.com/widgets/like.php?href=http://blogs.microsoft.co.il/blogs/arik/archive/2011/05/20/sela-developer-days-2011-save-the-date.aspx" scrolling="no" frameborder="0" style="border:none;width:130px;height:80px;"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.sela.co.il/"&gt;Sela Technology Center&lt;/a&gt; is proud to present &lt;a href="http://go.sela.co.il/msdp11"&gt;Sela Developer Days 2011&lt;/a&gt; which will be held on &lt;strong&gt;June 26-30&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/image_thumb_42F339DB_0B45FBE7.png"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="image_thumb_42F339DB" alt="image_thumb_42F339DB" src="http://blogs.microsoft.co.il/blogs/arik/image_thumb_42F339DB_thumb_263E7F5B.png" width="530" height="177" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;One stage - &lt;a href="http://www.sela.co.il/s/minisdp/tutorials2.html"&gt;hottest topics&lt;/a&gt; - &lt;a href="http://www.sela.co.il/s/minisdp/speakers.html"&gt;Israel and world lead experts&lt;/a&gt;.     &lt;br /&gt;A rare opportunity to hear all about the &lt;strong&gt;next&lt;/strong&gt; big things in our technological world.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;25 full-day workshops &lt;/li&gt;    &lt;li&gt;15 lead experts &lt;/li&gt;    &lt;li&gt;5 days &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;You can find the full agenda on the &lt;a href="http://go.sela.co.il/msdp11"&gt;conference website&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Although I recommend ALL the lectures, I believe my blog readers will most enjoy the following workshops:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;26/06&lt;/strong&gt; &lt;a href="http://www.sela.co.il/s/minisdp/tutorials2.html#263"&gt;Silverlight 5&lt;/a&gt; by &lt;a href="http://www.sela.co.il/s/minisdp/speakers.html#Alex1"&gt;Alex Golesh&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;27/06&lt;/strong&gt; &lt;a href="http://www.sela.co.il/s/minisdp/tutorials2.html#273"&gt;LOB Application Development with Silverlight&lt;/a&gt; by &lt;a href="http://www.sela.co.il/s/minisdp/speakers.html#Alex1"&gt;Alex Golesh&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;28/06&lt;/strong&gt; &lt;a href="http://www.sela.co.il/s/minisdp/tutorials2.html#283"&gt;Introduction to Windows Phone 7&lt;/a&gt; by &lt;a href="http://www.sela.co.il/s/minisdp/speakers.html#Tmoer1"&gt;Tomer Shamam&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;29/06&lt;/strong&gt; &lt;a href="http://www.sela.co.il/s/minisdp/tutorials2.html#292"&gt;Windows Phone Mango&lt;/a&gt; by &lt;a href="http://www.sela.co.il/s/minisdp/speakers.html#Alex1"&gt;Alex Golesh&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;30/06&lt;/strong&gt; &lt;a href="http://www.sela.co.il/s/minisdp/tutorials2.html#303"&gt;WPF and Silverlight - Smart Client Architecture Deep Dive with MVVM and Beyond&lt;/a&gt; by &lt;a href="http://www.sela.co.il/s/minisdp/speakers.html#Elad1"&gt;Elad Katz&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;See you there!&lt;/p&gt;  &lt;p&gt;That&amp;#39;s it for now,    &lt;br /&gt;Arik Poznanski.&lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=836636" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Sela/default.aspx">Sela</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Silverlight+5/default.aspx">Silverlight 5</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Mango/default.aspx">Mango</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/DevDays2011/default.aspx">DevDays2011</category></item><item><title>Managing Tombstone State in a Windows Phone 7 Application</title><link>http://blogs.microsoft.co.il/blogs/arik/archive/2011/05/01/managing-tombstone-state-in-a-windows-phone-7-application.aspx</link><pubDate>Sun, 01 May 2011 13:07:07 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:827230</guid><dc:creator>arik</dc:creator><slash:comments>9</slash:comments><description>&lt;p&gt;Before we continue, I trust that you know exactly the meaning of tombstone state in a Windows Phone 7 application. If this is not the case, simply read &lt;a href="http://windowsteamblog.com/members/yochay-kiriaty/"&gt;Yochay&lt;/a&gt;’s great posts on the application execution model (&lt;a href="http://windowsteamblog.com/windows_phone/b/wpdev/archive/2010/07/15/understanding-the-windows-phone-application-execution-model-tombstoning-launcher-and-choosers-and-few-more-things-that-are-on-the-way-part-1.aspx"&gt;Part 1&lt;/a&gt;, &lt;a href="http://windowsteamblog.com/windows_phone/b/wpdev/archive/2010/07/16/understanding-the-windows-phone-application-execution-model-tombstoning-launcher-and-choosers-and-few-more-things-that-are-on-the-way-part-2.aspx"&gt;Part 2&lt;/a&gt;, &lt;a href="http://windowsteamblog.com/windows_phone/b/wpdev/archive/2010/07/20/understanding-the-windows-phone-application-execution-model-tombstoning-launcher-and-more-part-3.aspx"&gt;Part 3&lt;/a&gt;).&lt;/p&gt;  &lt;p&gt;&lt;img style="display:block;float:none;margin-left:auto;margin-right:auto;" src="http://mobigyaan.com/images/stories/Writers/Kunal/windows-phone-logo.jpg" width="300" height="300" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;Every Windows Phone 7 application needs to manages tombstoning correctly to provide a better user experience and pass the &lt;a href="http://go.microsoft.com/?linkid=9730558"&gt;application certification requirements&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;When your application goes into tombstone state, it is your responsibility to save all the application and page state, so that when the page gets reloaded it can recover properly and reload the previous data. This was the user doesn’t even realizes that the application process got terminated and reloaded.&lt;/p&gt;  &lt;p&gt;To ease the handling of the tombstone state I’ve created a simple &lt;strong&gt;StateManager&lt;/strong&gt; class which helps serializing the data when going into tombstone state and deserializing the data when you get back.&lt;/p&gt;  &lt;h3&gt;How to Use StateManager?&lt;/h3&gt;  &lt;p&gt;Suppose your current page has the following data members you want to save across tombstoning:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;LastPosts &lt;/li&gt;    &lt;li&gt;Posts &lt;/li&gt;    &lt;li&gt;Comments &lt;/li&gt;    &lt;li&gt;Images &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Now all you need to do is to save them when the application goes into tombstone state and reload them when it gets back from tombstone state.&lt;/p&gt;  &lt;h4&gt;Saving the Data&lt;/h4&gt;  &lt;p&gt;The proper place for the code that saves the data resides in the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.page.onnavigatedfrom(v=vs.95).aspx"&gt;OnNavigatedFrom&lt;/a&gt; method. In this method you should call the helper extension method &lt;strong&gt;SaveState&lt;/strong&gt; for each member of the page that you want to save, passing the value and the key on which to save it:&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9bcbb912-cb9b-4069-80a3-b0620565990e" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;white-space:nowrap;"&gt;&lt;span style="color:#0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;override&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; OnNavigatedFrom(&lt;span style="color:#2b91af;"&gt;NavigationEventArgs&lt;/span&gt; e)&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.SaveState(&lt;span style="color:#a31515;"&gt;&amp;quot;LastPostsKey&amp;quot;&lt;/span&gt;, LastPosts);&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.SaveState(&lt;span style="color:#a31515;"&gt;&amp;quot;PostsKey&amp;quot;&lt;/span&gt;, Posts);&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.SaveState(&lt;span style="color:#a31515;"&gt;&amp;quot;CommentsKey&amp;quot;&lt;/span&gt;, Comments);&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.SaveState(&lt;span style="color:#a31515;"&gt;&amp;quot;ImagesKey&amp;quot;&lt;/span&gt;, Images);&lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;h4&gt;Loading the Data&lt;/h4&gt;  &lt;p&gt;The proper place for the code that loads the data when returning from tombstone state resides in &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.page.onnavigatedto(v=vs.95).aspx"&gt;OnNavigatedTo&lt;/a&gt; method. In this method you should call the helper extension method &lt;strong&gt;LoadState&lt;/strong&gt; for each member of the page that you want to load, passing the key related to the member’s value:&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:8074af33-ca3d-46d8-9196-019afd5d9a85" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;override&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; OnNavigatedTo(&lt;span style="color:#2b91af;"&gt;NavigationEventArgs&lt;/span&gt; e)&lt;br /&gt; {&lt;br /&gt;     LastPosts = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.LoadState&amp;lt;&lt;span style="color:#2b91af;"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;RssItem&lt;/span&gt;&amp;gt;&amp;gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;LastPostsKey&amp;quot;&lt;/span&gt;);&lt;br /&gt;     Posts = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.LoadState&amp;lt;&lt;span style="color:#2b91af;"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;RssItem&lt;/span&gt;&amp;gt;&amp;gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;PostsKey&amp;quot;&lt;/span&gt;);&lt;br /&gt;     Comments = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.LoadState&amp;lt;&lt;span style="color:#2b91af;"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;RssItem&lt;/span&gt;&amp;gt;&amp;gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;CommentsKey&amp;quot;&lt;/span&gt;);&lt;br /&gt;     Images = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.LoadState&amp;lt;&lt;span style="color:#2b91af;"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;ImageItem&lt;/span&gt;&amp;gt;&amp;gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;ImagesKey&amp;quot;&lt;/span&gt;);&lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;h3&gt;Definition of StateManager&lt;/h3&gt;  &lt;p&gt;So how is the &lt;strong&gt;StateManager&lt;/strong&gt; class defined? It is as simple as the following two extension methods:&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e290ed74-1266-4490-9f2d-b69d89fe84b9" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; State Manager&lt;/span&gt;&lt;br /&gt; &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;StateManager&lt;/span&gt;&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; Saves a key-value pair into the state object&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;param name=&amp;quot;phoneApplicationPage&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;The phone application page.&lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;param name=&amp;quot;key&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;The key.&lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;param name=&amp;quot;value&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;The value.&lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; SaveState(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;PhoneApplicationPage&lt;/span&gt; phoneApplicationPage, &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; key, &lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; value)&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (phoneApplicationPage.State.ContainsKey(key))&lt;br /&gt;         {&lt;br /&gt;             phoneApplicationPage.State.Remove(key);&lt;br /&gt;         }&lt;br /&gt; &lt;br /&gt;         phoneApplicationPage.State.Add(key, value);&lt;br /&gt;     }&lt;br /&gt; &lt;br /&gt;     &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; Loads value from the state object, according to the key.&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;typeparam name=&amp;quot;T&amp;quot;&amp;gt;&amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;param name=&amp;quot;phoneApplicationPage&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;The phone application page.&lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;param name=&amp;quot;key&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;The key.&lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;The loaded value&lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; T LoadState&amp;lt;T&amp;gt;(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;PhoneApplicationPage&lt;/span&gt; phoneApplicationPage, &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; key)&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;where&lt;/span&gt; T : &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt;&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (phoneApplicationPage.State.ContainsKey(key))&lt;br /&gt;         {&lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; (T)phoneApplicationPage.State[key];&lt;br /&gt;         }&lt;br /&gt; &lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;default&lt;/span&gt;(T);&lt;br /&gt;     }&lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Note: this code was first published as part of the “Using Pivot and Panorama Controls” lab found in the &lt;a href="http://msdn.microsoft.com/en-us/wp7trainingcourse_wp7silverlight_unit"&gt;Windows Phone Training Kit for Developers&lt;/a&gt;, which I wrote for Microsoft.&lt;/p&gt;  &lt;p&gt;That’s it for now,    &lt;br /&gt;Arik Poznanski.&lt;/p&gt;&lt;div class="wlWriterHeaderFooter" style="margin:0px;padding:0px 0px 0px 0px;"&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/05/01/managing-tombstone-state-in-a-windows-phone-7-application.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/05/01/managing-tombstone-state-in-a-windows-phone-7-application.aspx&amp;amp;bgcolor=6600FF" /&gt;&lt;/a&gt; &lt;a href="http://dotnetshoutout.com/Submit?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/05/01/managing-tombstone-state-in-a-windows-phone-7-application.aspx"&gt;&lt;img alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/05/01/managing-tombstone-state-in-a-windows-phone-7-application.aspx" style="border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=172641" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt; &lt;/div&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=827230" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Tombstone/default.aspx">Tombstone</category></item><item><title>MIX 2011: Enhanced Push Notifications and Live Tiles for Windows Phone</title><link>http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/15/mix-2011-enhanced-push-notifications-and-live-tiles-for-windows-phone.aspx</link><pubDate>Fri, 15 Apr 2011 14:58:38 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:818736</guid><dc:creator>arik</dc:creator><slash:comments>5</slash:comments><description>&lt;p&gt;This session was delivered by Thomas Fennel, Program manager, from Microsoft.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110414_133025_3AF94F3F.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110414_133025" alt="IMG_20110414_133025" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110414_133025_thumb_18A0F81F.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Thomas stated his session by showing what push notifications and tiles are.&lt;/p&gt;  &lt;p&gt;Push notification is how you can engage the user when your app is not on the foreground. Tiles are the squares on the Windows Phone home screen.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110414_133317_1ED7A8E0.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110414_133317" alt="IMG_20110414_133317" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110414_133317_thumb_1229B02A.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Toast notifications – on the top.&lt;/p&gt;  &lt;p&gt;Tile notifications – most popular – includes data for count, title (of app or arbitrary string) and background image.&lt;/p&gt;  &lt;p&gt;Then, Thomas explained the normal architecture for a push notification application:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110414_133753_67219C57.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110414_133753" alt="IMG_20110414_133753" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110414_133753_thumb_52ABB0FF.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Following are the typical scenarios / applications that you would want to use push notifications:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110414_134240_11014EE6.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110414_134240" alt="IMG_20110414_134240" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110414_134240_thumb_165F99BD.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This includes:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Weather apps&lt;/li&gt;    &lt;li&gt;Send to WP7 &lt;/li&gt;    &lt;li&gt;Turn based games&lt;/li&gt;    &lt;li&gt;Twitter clients&lt;/li&gt;    &lt;li&gt;Traffic map&lt;/li&gt;    &lt;li&gt;etc.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Thomas then continued with several code samples of these technologies.&lt;/p&gt;  &lt;p&gt;That’s it for now,   &lt;br /&gt;Arik Poznanski.&lt;/p&gt;&lt;div class="wlWriterHeaderFooter" style="margin:0px;padding:0px 0px 0px 0px;"&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/15/mix-2011-enhanced-push-notifications-and-live-tiles-for-windows-phone.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/15/mix-2011-enhanced-push-notifications-and-live-tiles-for-windows-phone.aspx&amp;amp;bgcolor=6600FF" /&gt;&lt;/a&gt; &lt;a href="http://dotnetshoutout.com/Submit?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/15/mix-2011-enhanced-push-notifications-and-live-tiles-for-windows-phone.aspx"&gt;&lt;img alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/15/mix-2011-enhanced-push-notifications-and-live-tiles-for-windows-phone.aspx" style="border:0px;" /&gt;&lt;/a&gt; &lt;/div&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=818736" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Sela/default.aspx">Sela</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/MIX+2011/default.aspx">MIX 2011</category></item><item><title>MIX 2011: Sensor and Camera Access in the Next Version of Windows Phone</title><link>http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/15/mix-2011-sensor-and-camera-access-in-the-next-version-of-windows-phone.aspx</link><pubDate>Fri, 15 Apr 2011 12:51:10 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:818703</guid><dc:creator>arik</dc:creator><slash:comments>5</slash:comments><description>&lt;p&gt;This session was delivered by Mark Paley, Principal Lead Program Manager from Microsoft.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110414_091553_2A3D3FAA.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110414_091553" alt="IMG_20110414_091553" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110414_091553_thumb_51278D85.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The next version of Windows Phone will support a few new sensors, like Gyro and Compass sensors.    &lt;br /&gt;Mark started the session by showing several camera and sensors demo.&lt;/p&gt;  &lt;p&gt;Some common usage scenario:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Sudoku solver &lt;/li&gt;    &lt;li&gt;Barcode scanner &lt;/li&gt;    &lt;li&gt;Custom photo application &lt;/li&gt;    &lt;li&gt;etc. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110414_090552_7CC831B4.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110414_090552" alt="IMG_20110414_090552" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110414_090552_thumb_2697BE76.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;So, what sensors are supported?&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Accelerometer – standard on all windows phone devices, provides acceleration data over 3 axis &lt;/li&gt;    &lt;li&gt;Compass – gives magnetic heading &lt;/li&gt;    &lt;li&gt;Gyroscope – gives rotation velocity (in radians per second) over 3 axis &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Mark showed a simple compass application:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110414_090927_6946E3E1.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110414_090927" alt="IMG_20110414_090927" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110414_090927_thumb_28F07ECD.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;And explained the compass measures bearing coordinate system.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110414_091054_4FAE6F40.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110414_091054" alt="IMG_20110414_091054" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110414_091054_thumb_39682E21.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Then Mark presented the new Motion sensor, which is basically all the sensors combined with some math and an easy interface.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110414_091210_1657BCB1.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110414_091210" alt="IMG_20110414_091210" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110414_091210_thumb_7497F5ED.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The motion sensor is the recommended sensor to use, if available.&lt;/p&gt;  &lt;p&gt;What it does is it combines the data from all 3 sensors (gyro, compass, accelerometer) to give more accurate information. Since every sensor has it’s own (different) stability problems, we can use all the data combined to eliminate correct the data.&lt;/p&gt;  &lt;p&gt;Mark also showed a nice demo of using the motion sensor and how it improves the stability of the measured data.&lt;/p&gt;  &lt;p&gt;The motion sensor provides its data in 3 representation: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Euler angles &lt;/li&gt;    &lt;li&gt;Rotation matrix &lt;/li&gt;    &lt;li&gt;Quaternion &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;All the sensors have similar API. They all got an &lt;strong&gt;IsSupported &lt;/strong&gt;property, i.e. &lt;strong&gt;Accelerometer.IsSupported&lt;/strong&gt;, &lt;strong&gt;Compass.IsSupported&lt;/strong&gt;, &lt;strong&gt;Gyroscope.IsSupported&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;To use any of the sensors, one needs to create an instance of the sensor, register for the &lt;strong&gt;CurrentValueChanged &lt;/strong&gt;event and start the sensor by using the &lt;strong&gt;Start() &lt;/strong&gt;method.&lt;/p&gt;  &lt;p&gt;The compass sometimes needs calibration and thus has a &lt;strong&gt;Calibrate &lt;/strong&gt;event which is raised when needed.&lt;/p&gt;  &lt;p&gt;Also, all sensors have a &lt;strong&gt;TimeBetweenUpdates &lt;/strong&gt;setting which controls how often does the event gets generated.&lt;/p&gt;  &lt;p&gt;The accelerometer sensor also supported a polling mode where one can use the property &lt;strong&gt;accelerometer.IsDataValid &lt;/strong&gt;and get the current value using &lt;strong&gt;accelerometer.CurrnetValue&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;Then, Mark showed another demo, this time using the motion sensor and XNA.&lt;/p&gt;  &lt;p&gt;So, when you shouldn&amp;#39;t use the motion sensor?&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;When you want data specific to the sensor reading &lt;/li&gt;    &lt;li&gt;When you want to do advanced usages like custom motion algorithms or gestures detection &lt;/li&gt;    &lt;li&gt;When &lt;strong&gt;Motion.IsSupported&lt;/strong&gt; is false. Note, the motion sensor will work even without a hardware gyroscope sensor &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Next, Mark started to talk about the camera sensor.&lt;/p&gt;  &lt;p&gt;He showed some demos and presented two ways of using the camera sensor:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Using the &lt;strong&gt;PhotoCamera&lt;/strong&gt; class, which is new in the next version of Windows Phone &lt;/li&gt;    &lt;li&gt;Using &lt;strong&gt;Silverlight 4 WebCam API&lt;/strong&gt;, ported from desktop SL, with a few features specific for phone &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;So, when should you use each API?&lt;/p&gt;  &lt;p&gt;You should use the &lt;strong&gt;PhotoCamera &lt;/strong&gt;class when you:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Want to take high resolution photos &lt;/li&gt;    &lt;li&gt;Want to handle the hardware camera button &lt;/li&gt;    &lt;li&gt;Want to handle focus and flash &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;You should use the &lt;strong&gt;WebCam API &lt;/strong&gt;when you:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Want to reuse Silverlight 4 knowledge&lt;/li&gt;    &lt;li&gt;Want to easily target desktop and phone&lt;/li&gt;    &lt;li&gt;Want to record video and audio into a file&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Next Mark showed another camera demo, using the &lt;strong&gt;PhotoCamera &lt;/strong&gt;class which has the following APIs:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;ButtonHalfPress &lt;/strong&gt;event – raised when the camera hardware button is half pressed&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;ButtonFullPress &lt;/strong&gt;event – raised when the camera hardware button is fully pressed&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;ButtonRelease &lt;/strong&gt;event – raised when the camera hardware button is released&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;CaptureCompleted &lt;/strong&gt;event – raised when the capture of an image is completed&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;camera.Focus() &lt;/strong&gt;method – will cause the camera to focus &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;camera.CaptureImage() &lt;/strong&gt;method – will starts to capture an image from the camera sensor&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;A few more things that are good to know:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Most scenarios requires hardware for debugging, only accelerometer and location have an emulator&lt;/li&gt;    &lt;li&gt;Motion sensors will try to return a result, even if not all 3 sensors exists&lt;/li&gt;    &lt;li&gt;The camera video output is MP4&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;That’s it for now,    &lt;br /&gt;Arik Poznanski.&lt;/p&gt;&lt;div class="wlWriterHeaderFooter" style="margin:0px;padding:0px 0px 0px 0px;"&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/15/mix-2011-sensor-and-camera-access-in-the-next-version-of-windows-phone.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/15/mix-2011-sensor-and-camera-access-in-the-next-version-of-windows-phone.aspx&amp;amp;bgcolor=6600FF" /&gt;&lt;/a&gt; &lt;a href="http://dotnetshoutout.com/Submit?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/15/mix-2011-sensor-and-camera-access-in-the-next-version-of-windows-phone.aspx"&gt;&lt;img alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/15/mix-2011-sensor-and-camera-access-in-the-next-version-of-windows-phone.aspx" style="border:0px;" /&gt;&lt;/a&gt; &lt;/div&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=818703" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Sela/default.aspx">Sela</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/MIX+2011/default.aspx">MIX 2011</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Mango/default.aspx">Mango</category></item><item><title>MIX 2011: What’s New in the Windows Phone Developer Tools</title><link>http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/14/mix-2011-what-s-new-in-the-windows-phone-developer-tools.aspx</link><pubDate>Thu, 14 Apr 2011 16:17:23 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:818461</guid><dc:creator>arik</dc:creator><slash:comments>5</slash:comments><description>&lt;p&gt;This mini-session was delivered by Vibhor Agarwal, Senior Program Manager from Microsoft.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_143633_37718058.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110413_143633" alt="IMG_20110413_143633" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_143633_thumb_47E92FAC.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Vibhor presented only the new Emulator enhancements and the new profiler provided in the next version of the developer tools.&lt;/p&gt;  &lt;p&gt;Some of the new emulator enhancements:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Memory model improvements &lt;/li&gt;    &lt;li&gt;Media support for H.264, AAC &lt;/li&gt;    &lt;li&gt;Sensor support – Accelerometer and Location &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Vibhor showed a demo about the new accelerometer emulation:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_144315_03D525C8.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110413_144315" alt="IMG_20110413_144315" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_144315_thumb_7AF4F7AE.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;and new location emulation:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_144441_13083C3D.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110413_144441" alt="IMG_20110413_144441" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_144441_thumb_08774250.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Then, Vibhor presented how one can use the new profiler to analyze a windows phone application for finding performance issues.&lt;/p&gt;  &lt;p&gt;The profiler has two supported modes, execution profiling and memory profiling. It was suggested that the memory profiler should be used only when you are sure this is actually a problem. The starting point should be the execution profiling.&lt;/p&gt;  &lt;p&gt;We’ve seen several different graphs, including:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Frame Rate graph &lt;/li&gt;    &lt;li&gt;CPU usage % &lt;/li&gt;    &lt;li&gt;Memory usage &lt;/li&gt;    &lt;li&gt;Storyboards &lt;/li&gt;    &lt;li&gt;Image loads &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_145129_7C45A25B.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110413_145129" alt="IMG_20110413_145129" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_145129_thumb_698082D7.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Of course, we can drill down and see how much CPU time we have spent in each function, like any normal profiler.&lt;/p&gt;  &lt;p&gt;It should be noted that the profiler is a CPU sampling based profiler.&lt;/p&gt;  &lt;p&gt;Also shown was the profiler analyzer that searches for common anti-patterns that developers sometimes use and recommends how to detect issues related to them.&lt;/p&gt;  &lt;p&gt;All in all, very interesting presentation of an important tool.&lt;/p&gt;  &lt;p&gt;That’s it for now,    &lt;br /&gt;Arik Poznanski.&lt;/p&gt;&lt;div class="wlWriterHeaderFooter" style="margin:0px;padding:0px 0px 0px 0px;"&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/14/mix-2011-what-s-new-in-the-windows-phone-developer-tools.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/14/mix-2011-what-s-new-in-the-windows-phone-developer-tools.aspx&amp;amp;bgcolor=6600FF" /&gt;&lt;/a&gt; &lt;a href="http://dotnetshoutout.com/Submit?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/14/mix-2011-what-s-new-in-the-windows-phone-developer-tools.aspx"&gt;&lt;img alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/14/mix-2011-what-s-new-in-the-windows-phone-developer-tools.aspx" style="border:0px;" /&gt;&lt;/a&gt; &lt;/div&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=818461" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Sela/default.aspx">Sela</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/MIX+2011/default.aspx">MIX 2011</category></item><item><title>MIX 2011: Get Ready for Fast Application Switching in Windows Phone</title><link>http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/14/mix-2011-get-ready-for-fast-application-switching-in-windows-phone.aspx</link><pubDate>Thu, 14 Apr 2011 16:07:35 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:818458</guid><dc:creator>arik</dc:creator><slash:comments>7</slash:comments><description>&lt;p&gt;This mini-session was delivered by Adina Trufinescu.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_141541_4BAEEC31.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110413_141541" alt="IMG_20110413_141541" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_141541_thumb_056DBDB7.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The agenda for this session was:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Application Resume User Experience &lt;/li&gt;    &lt;li&gt;Application Lifecycle &lt;/li&gt;    &lt;li&gt;Phone Resource Management &lt;/li&gt;    &lt;li&gt;Key Developer Scenarios &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Adina started by discussing the next version of Windows Phone, codenamed &lt;strong&gt;Mango&lt;/strong&gt;, where there is much improvements in the area of returning to a previously active application.&lt;/p&gt;  &lt;p&gt;To take advantage of this in your application you will need to recompile your application against the new developers tools.&lt;/p&gt;  &lt;p&gt;Adina then explained the new application lifecycle in Mango, which includes a new “dormant” state.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_140645_2F2112DD.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110413_140645" alt="IMG_20110413_140645" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_140645_thumb_09C3F2E4.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_140742_62A933A1.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110413_140742" alt="IMG_20110413_140742" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_140742_thumb_663728B1.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This “dormant” state is another stage before tombstoning. In this state the application resources are almost entirly freed, except memory usage but the process is not closed.    &lt;br /&gt;So, returning from a dormant state doesn’t requires you to deserialize your data and reload state. Only if the application was actually tombstoned you must reload your state.&lt;/p&gt;  &lt;p&gt;To know whether you came back from “dormant” state or “tombstoned” state you can check a new property named IsAppInstancePreserved.&lt;/p&gt;  &lt;p&gt;Adina then presented exactly what kind of resources are cleaned on “dormant” state and who is in charge of getting them back once reactivated.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_141334_7B652E59.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110413_141334" alt="IMG_20110413_141334" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_141334_thumb_4CAED9DD.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_141530_0BFC67A1.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110413_141530" alt="IMG_20110413_141530" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_141530_thumb_3F848865.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;That’s it for now,    &lt;br /&gt;Arik Poznanski.&lt;/p&gt;&lt;div class="wlWriterHeaderFooter" style="margin:0px;padding:0px 0px 0px 0px;"&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/14/mix-2011-get-ready-for-fast-application-switching-in-windows-phone.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/14/mix-2011-get-ready-for-fast-application-switching-in-windows-phone.aspx&amp;amp;bgcolor=6600FF" /&gt;&lt;/a&gt; &lt;a href="http://dotnetshoutout.com/Submit?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/14/mix-2011-get-ready-for-fast-application-switching-in-windows-phone.aspx"&gt;&lt;img alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/14/mix-2011-get-ready-for-fast-application-switching-in-windows-phone.aspx" style="border:0px;" /&gt;&lt;/a&gt; &lt;/div&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=818458" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Sela/default.aspx">Sela</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/MIX+2011/default.aspx">MIX 2011</category></item><item><title>MIX 2011: Day 2 Keynotes Summary</title><link>http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/14/mix-2011-day-2-keynotes-summary.aspx</link><pubDate>Thu, 14 Apr 2011 14:01:34 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:818423</guid><dc:creator>arik</dc:creator><slash:comments>3</slash:comments><description>&lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/gilf/archive/2011/04/13/mix11-second-keynote-session-summary.aspx"&gt;Yet&lt;/a&gt; &lt;a href="http://blogs.microsoft.co.il/blogs/eshaham/archive/2011/04/14/mix11-windows-phone-keynote-presentation.aspx"&gt;another&lt;/a&gt; &lt;a href="http://blogs.microsoft.co.il/blogs/idof/archive/2011/04/14/mix-2011-day-2.aspx"&gt;post&lt;/a&gt; on MIX 2011 second day keynotes.&lt;/p&gt;  &lt;p&gt;The Keynotes started by Joe Belfiore presenting some information about how Windows Phone Updates are done.   &lt;br /&gt;Specifically, Joe answered the common questions:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Why the update came later than anticipated? (deployments bugs..)&lt;/li&gt;    &lt;li&gt;Who decides when to update? (MS and the operators)&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_090710_73F57FD2.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110413_090710" alt="IMG_20110413_090710" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_090710_thumb_6F0F79BE.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Joe stated that there are currently almost 13K apps in the Windows Phone market.    &lt;br /&gt;The next edition of Windows Phone Ecosystem will support 16 additional languages and up to 35 countries will be able to both publish and consume applications from the market.&lt;/p&gt;  &lt;p&gt;The new version of Windows Phone 7 was announced, codename &lt;strong&gt;Mango&lt;/strong&gt;.    &lt;br /&gt;Among its capabilities:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Internet Explorer 9 on the phone, with the same HTML 5 support. There was a nice comparison of the mobile browsers iPhone vs. Android vs. Windows Phone Mango.&lt;/li&gt;    &lt;li&gt;Enable custom ringtones&lt;/li&gt;    &lt;li&gt;Improved Panorama and Pivot controls&lt;/li&gt;    &lt;li&gt;Sockets support&lt;/li&gt;    &lt;li&gt;Built-in SQL Server&lt;/li&gt;    &lt;li&gt;More launchers and choosers&lt;/li&gt;    &lt;li&gt;Calendar integration&lt;/li&gt;    &lt;li&gt;Motion Sensor&lt;/li&gt;    &lt;li&gt;Multi-tasking via fast application switching and running certain apps in the background.&lt;/li&gt;    &lt;li&gt;and many more…&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_094102_03C126A5.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110413_094102" alt="IMG_20110413_094102" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_094102_thumb_355BF860.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;A Motion Sensor now wraps the complex math around the accelerometer and compass sensors.&lt;/p&gt;  &lt;p&gt;Then Scott Guthrie came to the stage and presented some new features of the Mango developer tools like the accelerometer emulation and location emulation.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_095508_32A316E2.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110413_095508" alt="IMG_20110413_095508" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_095508_thumb_3F8CD126.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;And the new Windows Phone profiler that will come free as part of the developer tools.&lt;/p&gt;    &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_095835_3935D4CB.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110413_095835" alt="IMG_20110413_095835" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_095835_thumb_637DA64F.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Scott also presented many performance optimizations that where done in the Mango operating system, specifically in the following areas:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Getting user input while scrolling&lt;/li&gt;    &lt;li&gt;Decoding images loaded from the net&lt;/li&gt;    &lt;li&gt;Garbage collection&lt;/li&gt;    &lt;li&gt;Memory usage&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Also in Mango, support for Silverlight 4, this is a nice improvement that didn’t got enough attention, IMHO.&lt;/p&gt;  &lt;p&gt;Next &lt;a href="http://www.silverlight.net/getstarted/silverlight-5-beta/"&gt;Silverlight 5 Beta&lt;/a&gt; was announced to be available for download.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_102544_22CB3413.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110413_102544" alt="IMG_20110413_102544" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_102544_thumb_49A14822.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Silverlight 5 presents many new features, among them:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Media improvements (hardware accelerated decoding)&lt;/li&gt;    &lt;li&gt;New 3D XNA-based APIs &lt;/li&gt;    &lt;li&gt;Binding in style setters&lt;/li&gt;    &lt;li&gt;Implicit data template&lt;/li&gt;    &lt;li&gt;Data binding debugging&lt;/li&gt;    &lt;li&gt;and more…&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Finally, the Kinect SDK for Windows was announced with a small surprise: every MIX attendee will get a free Kinect sensor to play with at home…&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_104443_74F5434F.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110413_104443" alt="IMG_20110413_104443" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110413_104443_thumb_4E73146A.jpg" width="637" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;That’s it for now,   &lt;br /&gt;Arik Poznanski.&lt;/p&gt;&lt;div class="wlWriterHeaderFooter" style="margin:0px;padding:0px 0px 0px 0px;"&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/14/mix-2011-day-2-keynotes-summary.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/14/mix-2011-day-2-keynotes-summary.aspx&amp;amp;bgcolor=6600FF" /&gt;&lt;/a&gt; &lt;a href="http://dotnetshoutout.com/Submit?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/14/mix-2011-day-2-keynotes-summary.aspx"&gt;&lt;img alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/14/mix-2011-day-2-keynotes-summary.aspx" style="border:0px;" /&gt;&lt;/a&gt; &lt;/div&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=818423" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Sela/default.aspx">Sela</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/MIX+2011/default.aspx">MIX 2011</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Kinect/default.aspx">Kinect</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Silverlight+5/default.aspx">Silverlight 5</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Mango/default.aspx">Mango</category></item><item><title>MIX 2011: Deep Dive MVVM</title><link>http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/13/mix-2011-deep-dive-mvvm.aspx</link><pubDate>Wed, 13 Apr 2011 16:26:18 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:818183</guid><dc:creator>arik</dc:creator><slash:comments>6</slash:comments><description>&lt;p&gt;This session was delivered by &lt;a href="http://www.galasoft.ch/"&gt;Laurent Bugnion&lt;/a&gt;, the creator of &lt;a href="http://www.galasoft.ch/mvvm/"&gt;MVVM Light&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/IMG_20110412_140743_5ACFE5F8.jpg"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="IMG_20110412_140743" alt="IMG_20110412_140743" src="http://blogs.microsoft.co.il/blogs/arik/IMG_20110412_140743_thumb_5504A685.jpg" width="361" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In this session Laurent talked about advanced MVVM topics that every WPF/SL developer face sooner or later.&lt;/p&gt;  &lt;p&gt;Laurent used a demo application an showed how to solve some common issues.&lt;/p&gt;  &lt;p&gt;For example, how can one share view-models between several different platforms (Silverlight / WP7), short answer: add shared files as links.&lt;/p&gt;  &lt;p&gt;Also discussed: what strategy should be used to create view-models and exposes them. Short answer: Either create them in advance and expose them as properties or generate them on the fly, this is of course scenario-dependent.&lt;/p&gt;  &lt;p&gt;Laurent also discussed the ancient MVVM question of how can one open a dialog from the view-model (short answer: IDialogService), or navigate from the view-model (S.A.: INavigationService) or invoking animations from the view-model (S.A.: States + Behaviors).&lt;/p&gt;  &lt;p&gt;Finally Laurent discussed some common issues when unit-testing view-models.&lt;/p&gt;  &lt;p&gt;All in all, it was an excellent lecture. It’s always nice to see top developers struggles with the same issues you face on the everyday. And if you have the same solution that’s also something..&lt;/p&gt;  &lt;p&gt;That’s it for now,   &lt;br /&gt;Arik Poznanski.&lt;/p&gt;&lt;div class="wlWriterHeaderFooter" style="margin:0px;padding:0px 0px 0px 0px;"&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/13/mix-2011-deep-dive-mvvm.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/13/mix-2011-deep-dive-mvvm.aspx&amp;amp;bgcolor=6600FF" /&gt;&lt;/a&gt; &lt;a href="http://dotnetshoutout.com/Submit?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/13/mix-2011-deep-dive-mvvm.aspx"&gt;&lt;img alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/13/mix-2011-deep-dive-mvvm.aspx" style="border:0px;" /&gt;&lt;/a&gt; &lt;/div&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=818183" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Sela/default.aspx">Sela</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/MIX+2011/default.aspx">MIX 2011</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/MVVM/default.aspx">MVVM</category></item><item><title>Shake Gestures Library – A Windows Phone Recipe</title><link>http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/01/shake-gestures-library-a-windows-phone-recipe.aspx</link><pubDate>Sat, 02 Apr 2011 03:34:51 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:815736</guid><dc:creator>arik</dc:creator><slash:comments>9</slash:comments><description>&lt;p&gt;Note: the following article was first published as part of the Windows Phone Recipe “Shake Gestures Library” found &lt;a href="http://create.msdn.com/en-us/education/catalog/article/Recipe_Shake_Gesture_Library"&gt;here&lt;/a&gt;, which I wrote for Microsoft, together with &lt;a href="http://windowsteamblog.com/members/yochay-kiriaty/"&gt;Yochay Kiriaty&lt;/a&gt;.&lt;/p&gt;  &lt;h3&gt;Document Purpose&lt;/h3&gt;  &lt;p&gt;This document introduces a helper library for identifying shake gestures by using the accelerometer built into Windows Phone 7 devices. It explains how to use the library, how the library works internally, and how you can configure the library’s parameters to adapt gesture detection to your needs. &lt;/p&gt;  &lt;h3&gt;Library Features&lt;/h3&gt;  &lt;p&gt;The shake gestures library uses the accelerometer to detect movement in three directions:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Left-Right (X direction)&lt;/li&gt;    &lt;li&gt;Top-Bottom (Y direction)&lt;/li&gt;    &lt;li&gt;Forward-Backward (Z direction)&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;If you’re looking for a general purpose shake gesture and don’t care about the direction of the gesture, then you can simply use any combination of one or more of the supported gestures. However, sometimes you need to have better control and to understand if the gesture was in the “right” direction. &lt;/p&gt;  &lt;h3&gt;How to Use the Shake Gesture Library&lt;/h3&gt;  &lt;p&gt;Since the shake gesture library is doing all the heavy lifting for you, using the library requires very little effort from you. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Step 1&lt;/u&gt;&lt;/b&gt;: Add reference to shake gestures library: &lt;b&gt;ShakeGestures.dll&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Step 2&lt;/u&gt;&lt;/b&gt;: Add a &lt;b&gt;using&lt;/b&gt; statement to file header&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:97743ae4-3848-4874-b6a9-f9d45a74c8a0" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; ShakeGestures;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Step 3&lt;/u&gt;&lt;/b&gt;: Register to &lt;b&gt;ShakeGesture&lt;/b&gt; event&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:387a10c3-bcd8-47ca-804c-f5d988b8601f" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#008000;"&gt;// register shake event&lt;/span&gt;&lt;br /&gt; &lt;span style="color:#2b91af;"&gt;ShakeGesturesHelper&lt;/span&gt;.Instance.ShakeGesture += &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;EventHandler&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;ShakeGestureEventArgs&lt;/span&gt;&amp;gt;(Instance_ShakeGesture);&lt;br /&gt; &lt;br /&gt; &lt;span style="color:#008000;"&gt;// optional, set parameters&lt;/span&gt;&lt;br /&gt; &lt;span style="color:#2b91af;"&gt;ShakeGesturesHelper&lt;/span&gt;.Instance.MinimumRequiredMovesForShake = 5;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Step 4&lt;/u&gt;&lt;/b&gt;: implement the &lt;b&gt;ShakeGesture&lt;/b&gt; event handler from step 3&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9bef5a89-9a93-48d0-bf17-7a310c15e2dd" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Instance_ShakeGesture(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;ShakeGestureEventArgs&lt;/span&gt; e)&lt;br /&gt; {&lt;br /&gt;     _lastUpdateTime.Dispatcher.BeginInvoke(&lt;br /&gt;         () =&amp;gt;&lt;br /&gt;         {&lt;br /&gt;             _lastUpdateTime.Text = &lt;span style="color:#2b91af;"&gt;DateTime&lt;/span&gt;.Now.ToString();&lt;br /&gt;             CurrentShakeType = e.ShakeType;&lt;br /&gt;         });&lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/p&gt;  &lt;p&gt;The &lt;b&gt;ShakeGestureEventArgs&lt;/b&gt; holds a ShakeType property that identifies the direction of the shake gesture.&lt;/p&gt;  &lt;p&gt;Finally, you need to activate the library, which binds to the phone’s accelerometer and starts listening to incoming sensor input events. &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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7acc2026-95c8-46ba-b1b2-483800ea78f5" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#008000;"&gt;// start shake detection&lt;/span&gt;&lt;br /&gt; &lt;span style="color:#2b91af;"&gt;ShakeGesturesHelper&lt;/span&gt;.Instance.Active = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;Note&lt;/i&gt;&lt;/b&gt;&lt;i&gt;: You can continue working directly with the phone’s sensor. The ShakeGesturesHelper class doesn’t block any sensor events—it just listens to them.&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;Note&lt;/i&gt;&lt;/b&gt;&lt;i&gt;: The &lt;b&gt;ShakeGesture&lt;/b&gt; event arrives on a thread different from the UI thread, so if you want to update the UI from this event you should dispatch your code to run on the UI thread. This can be done by using the method myControl.&lt;/i&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.begininvoke(VS.95).aspx"&gt;&lt;i&gt;Dispatcher.BeginInvoke&lt;/i&gt;&lt;/a&gt;&lt;i&gt;(), where myControl is the control you want to update.&lt;/i&gt;&lt;/p&gt;  &lt;h3&gt;How Does the Shake Gesture Library Work?&lt;/h3&gt;  &lt;p&gt;We need to figure out what a shake gesture is and how to identify a shake when it occurs. Then we need to classify the shake according to the gesture direction. &lt;/p&gt;  &lt;p&gt;The accelerometer sensor in a Windows Phone measures the gravity forces applied on the phone and reports an &lt;b&gt;AccelerometerReading &lt;/b&gt;event about 50 times per second. When you move the phone up and down in 3D space, you’re getting a lot of readings (the sensors are quite noisy), and you don’t really know the phone’s orientation or the distance that the phone moved, since all you have are changes in the relative gravity force on the phone during a given period of time. &lt;/p&gt;  &lt;p&gt;With that in mind, we set out to create a simple, high-performance shake gesture library, and came up with the following shake gestures detection process:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Noise reduction&lt;/li&gt;    &lt;li&gt;Segmentation into &amp;quot;Shake&amp;quot; and &amp;quot;Still&amp;quot; signal segments&lt;/li&gt;    &lt;li&gt;Shake direction classification&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;We report sensor readings as vectors, since we obtain 3-axis readings (X, Y, and Z, with each having a double value associated with it). We can set the initial point to (0, 0, 0), hence a &lt;a href="http://en.wikipedia.org/wiki/Euclidean_vector"&gt;vector&lt;/a&gt;. &lt;/p&gt;  &lt;h4&gt;Noise Reduction&lt;/h4&gt;  &lt;p&gt;Before performing gesture detection, the noise must be removed from the accelerometer’s input vectors. This is done by passing the raw input vectors through a low-pass filter. This smooth the signal so that it ignores small changes and only takes into account any “large enough” changes. We’re using an existing noise reduction implementation by Dave Edson. For more details on Dave’s algorithm, check out this &lt;a href="http://windowsteamblog.com/windows_phone/b/wpdev/archive/2010/09/08/using-the-accelerometer-on-windows-phone-7.aspx"&gt;blog post&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/image_08F63210.png"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="image" alt="image" src="http://blogs.microsoft.co.il/blogs/arik/image_thumb_3BE5C277.png" width="355" height="311" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="center"&gt;Figure 1: Before noise reduction&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/image_40E80026.png"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="image" alt="image" src="http://blogs.microsoft.co.il/blogs/arik/image_thumb_5113C81F.png" width="437" height="311" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="center"&gt;Figure 2: After noise reduction&lt;/p&gt;  &lt;p&gt;As you can see, the signal after noise reduction is much cleaner and easier to work with. &lt;/p&gt;  &lt;h4&gt;Segmentation into Shake and Still Signal Segments&lt;/h4&gt;  &lt;p&gt;After cleaning the signal, our next step is to separate shake and still segments. Basically, we want to identify shake segments when the following conditions are satisfied:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;The magnitude of one or more of the vectors (X, Y, or Z) crosses a certain threshold. &lt;/li&gt;    &lt;li&gt;The vector stays above this threshold long enough so that we don’t mistake a one-time blip for a shake. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;Note&lt;/i&gt;&lt;/b&gt;&lt;i&gt;: We don’t use a system timer to measure time. Instead, we depend on the fact that the Windows Phone sensor generates about 50 events per second, so the time between each event is around 20 msec. Therefore, five events total roughly 100 msec&lt;/i&gt;. You’ll see in the code that we measure event intervals and not real world clock time.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/image_3D1A3589.png"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="image" alt="image" src="http://blogs.microsoft.co.il/blogs/arik/image_thumb_0F88EFF9.png" width="529" height="432" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="center"&gt;Figure 3: Signal segmentation&lt;/p&gt;  &lt;p&gt;Ignore for a second how we calculate vector magnitudes; we’ll address that topic in the next section. For now, look at Figure 3. You can see from the green line pattern that it’s very clear when the phone was in a shake segment and when it was in a still segment. Therefore, our goal is to be able to understand when a series of vectors represents a shake segment. Once we identify a shake segment, we’ll further process it to extract the shake type and raise the shake event. &lt;/p&gt;  &lt;h5&gt;Calculating Gravitation Vectors&lt;/h5&gt;  &lt;p&gt;To start with, we need a reference point that reflects the still state of the phone. The Still segment is used to compute something we call the &lt;b&gt;last-known-gravitation-vector&lt;/b&gt;. The last-known-gravitation-vector will be used later to eliminate the effect of gravitation when classifying the shake type.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;Note&lt;/i&gt;&lt;/b&gt;&lt;i&gt;: We can&amp;#39;t assume that the gravitation vector will always have the value (0,-1, and 0) for two reasons:&lt;/i&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Gravity isn’t exactly &lt;a href="http://en.wikipedia.org/wiki/Standard_gravity"&gt;1G&lt;/a&gt; everywhere on earth. It varies somewhat according to location and altitude.&lt;/li&gt;    &lt;li&gt;The direction of the gravity vector depends on how you hold your phone. If you rotate it, the direction varies. If you’re moving, your hand direction varies.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;To calculate the gravitation vector, we take the most recent vectors in the still signal (&lt;a&gt;MaximumStillVectorsNeededForAverage&lt;/a&gt; parameter) and average the vectors that have very low magnitude (&lt;a&gt;StillMagnitudeWithoutGravitationThreshold&lt;/a&gt; parameters. In case we don&amp;#39;t have enough still vectors for a representative sample (&lt;a&gt;MinimumStillVectorsNeededForAverage&lt;/a&gt; parameter), we abort the calculation, since we won&amp;#39;t get a valid gravitation vector. &lt;/p&gt;  &lt;p&gt;The gravitation vector is re-calculated for each new still segment that we get, to account for any changes in how you hold your phone. Remember that we’re looking for real time effects; therefore, we need to maintain an accurate state of the current gravitation forces that are affecting the phone. &lt;/p&gt;  &lt;h5&gt;Finding Signal Boundaries&lt;/h5&gt;  &lt;p&gt;Now, let’s assume the user starts shaking his phone. We need to find the shake segment starting and ending points. To do so, we use the following algorithm:&lt;/p&gt;  &lt;p&gt;There are only two possible states: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;Shake state&lt;/b&gt; – Indicates that we’re currently in the middle of a shake signal&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Still state&lt;/b&gt; – Indicates that we’re currently in the middle of a still signal (that is, not in the middle of a shake signal)&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Based on the current state and the input vector type, we decide what the next step is. Each time we get a new input vector from the accelerometer (after noise reduction), we check whether the vector magnitude is equal or larger than a certain shake threshold &lt;a&gt;ShakeMagnitudeWithoutGravitationThreshold&lt;/a&gt; parameter. If it’s larger, then this input vector is addressed as a potential shake vector. Otherwise, it’s considered a still vector. &lt;/p&gt;  &lt;p&gt;Per each input vector and the current “shake” state we use the following state-machine to determine the next state…&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;Condition:&lt;/b&gt; The current state of the phone is still, and the new vector has a still magnitude value.&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Operation: &lt;/b&gt;Add the vector to the still signal array (the array is a cyclic array).&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Condition:&lt;/b&gt; The current state of the phone is still, and the new input vector has a magnitude that is higher than the minimum shake threshold.&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Operation: &lt;/b&gt;Set shake state, process still signal, add vector to shake signal array (this doesn’t mean that we identified a shake, we’re just adding it to the array for further processing later).&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Condition: &lt;/b&gt;The current phone state is shake, and the new input vector has a shake magnitude.&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Operation: &lt;/b&gt;Add vector to shake signal, try to process shake signal array. Here we’re actually trying to identify a shake, since we already got a few shake vectors in the array. Again, we need to wait for the minimum amount of shake vector before we can start processing a shake single. &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Condition:&lt;/b&gt; The current phone state is shake, and the new input vector has a still magnitude (it’s below the minimum shake magnitude).&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Operation:&lt;/b&gt; Add vector to shake signal, unless we’ve already received too many sequential still vectors (&lt;a&gt;StillCounterThreshold &lt;/a&gt;parameter), in which case move the still vectors to the still signal and change the phone state to still state.&lt;/li&gt; &lt;/ul&gt;  &lt;h4&gt;Shake Type Classification&lt;/h4&gt;  &lt;p&gt;It’s time to dive into the actual vector processing. The following describes the algorithm we’re using, but for performance reasons the code performs some of the processing while the shake vectors are being collected, but the idea remains the same.&lt;/p&gt;  &lt;h5&gt;Neutralizing Gravitation Effects (Removing Earth Gravity Effects)&lt;/h5&gt;  &lt;p&gt;All input vectors include the earth’s gravitation forces. And since we don’t have any idea about the position of your phone in 3D space, we don’t know which of the vectors (X, Y, or Z) is affected by the earth’s gravity. Therefore, we need to remove the earth’s gravity effect.&lt;/p&gt;  &lt;p&gt;To eliminate the effect of gravity, we first reduce the last known gravitation vector from all the vectors in the shake signal. In this way, when we get acceleration in some axis we can be certain that the user moved the phone along that axis instead of wondering whether this is just the force of gravity trying to fool us. Therefore, for each input vector we’re subtracting the last known gravity vector. &lt;/p&gt;  &lt;h5&gt;Finding Shake Main Direction&lt;/h5&gt;  &lt;p&gt;Now we want to find the main direction of the shake signal, which can be one of the following three directions:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;X (left-right)&lt;/li&gt;    &lt;li&gt;Y (top-bottom)&lt;/li&gt;    &lt;li&gt;Z (forward-backward)&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;To do this, we first need to find the main direction of each vector in the shake signal. We do this by checking which of the vector products has the biggest absolute value. To get a better feeling of why we’re breaking the vector into its products, let’s review a 2D vector. As you can see in Figure 4, the red vector products are broken into the X and Y values [Red value = sqrt(pow(x,2) + pow(y,2))].&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/image_2F27A3F4.png"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="image" alt="image" src="http://blogs.microsoft.co.il/blogs/arik/image_thumb_4D91E4DD.png" width="249" height="226" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="center"&gt;Figure 4: Illustration of classifying a 2D vector&lt;/p&gt;  &lt;p&gt;It’s clear that the red vector should be classified as an X axis vector, because its X product is much stronger than its Y product. The same methodology is implemented in the library for 3D vectors.&lt;/p&gt;  &lt;p&gt;At this stage, we’ve got a vector that isn’t affected by the earth’s gravity, we’ve broken the vector into its products, and we know the main direction of the vector. &lt;/p&gt;  &lt;p&gt;Our next step is to create a histogram of the vectors’ products, and then to select the direction with the most products in it. Remember, we started with a vector whose magnitude is strong enough to be considering a &lt;b&gt;shake &lt;/b&gt;vector. We removed the earth’s gravity effect, and we broke it into its distinct products, and classified them. For example, Figure 5 shows a histogram of a shake signal that has most of its vectors pointing in X direction, hence the shake signal’s main direction will be X. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/image_1DF3C651.png"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="image" alt="image" src="http://blogs.microsoft.co.il/blogs/arik/image_thumb_431110BD.png" width="260" height="289" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="center"&gt;Figure 5: Histogram of vector directions in a shake signal&lt;/p&gt;  &lt;p&gt;To prevent weak vectors (&lt;a&gt;WeakMagnitudeWithoutGravitationThreshold&lt;/a&gt; parameter) that got into the shake signal from affecting the histogram result, we’ll only consider vectors above a certain threshold when calculating the histogram.&lt;/p&gt;  &lt;p&gt;In addition, we’ll consider the histogram result as valid only if the number of vectors in the main direction passes a certain threshold (&lt;a&gt;MinimumShakeVectorsNeededForShake&lt;/a&gt; parameter). This will enable us to eliminate false results due to histograms done on small amounts of data.&lt;/p&gt;  &lt;h5&gt;Recognizing the Gesture &lt;/h5&gt;  &lt;p&gt;Up until now, we’ve identified a movement of the phone in 3D space that’s fast (powerful) enough to be consider a shake. Basically, we know the shake signal’s axis, but that isn’t sufficient. In order to make sure the movement we detected is really a shake gesture, and not just a random (single) movement in one direction, we need to count several intervals of movement and, more importantly, changes in the vector direction. A shake is defined as a movement of the phone on one axis back and forth a few times.&lt;/p&gt;  &lt;p&gt;To check whether the shake signal is a shake gesture, we’ll check the sign of the main direction coordinate. For example, if we found that the main direction of our shake signal was X, then we’ll inspect the sign of the X products of all the vectors in the signal. On a real shake gesture, we expect the sign to change a few times, since we move the phone back and forth and thus keep changing the force (acceleration), which translates to a direction change. &lt;/p&gt;  &lt;p&gt;For example, in the following figure we see a normalized (without gravitation) shake signal of a real shake gesture. You can clearly see the main direction being Z, and the Z values go back and forth between positive and negative.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/image_682E5B29.png"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="image" alt="image" src="http://blogs.microsoft.co.il/blogs/arik/image_thumb_2C8E4C69.png" width="385" height="231" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="center"&gt;Figure 6: Example of a shake vector&lt;/p&gt;  &lt;p&gt;In order to identify the gesture, we’ll count how many times the X values goes from positive to negative and back. If the count is bigger than &lt;a&gt;MinimumRequiredMovesForShake&lt;/a&gt;, we’ll finally raise the shake gesture event!&lt;/p&gt;  &lt;h3&gt;Configuring Parameters&lt;/h3&gt;  &lt;p&gt;During the coding and testing of the library, we found that shake is very individualized. It depends on the nature of the application and the actual shake gesture made by the phone’s user. There are alternative algorithms available that are adaptive and learning algorithms. While these might be more accurate, they require a learning phase that we didn’t want to force on the end user and on the developer building the app. Therefore, we give you plenty of different properties to tweak and tune for your own purposes. &lt;/p&gt;  &lt;p&gt;These parameters control various aspects of the gesture detection algorithm. By changing these parameters, you can change your application’s sensitivity to shakes and to the duration of a shake. All parameters have default values kept as constants in the library.&lt;/p&gt;  &lt;p&gt;The following section describes the available parameters. Each parameter is mentioned in context in the above algorithm.&lt;/p&gt;  &lt;h4&gt;ShakeMagnitudeWithoutGravitationThreshold&lt;/h4&gt;  &lt;p&gt;&lt;b&gt;Description&lt;/b&gt;: Any vector that has a magnitude (after reducing gravitation force) bigger than this parameter value is considered as a shake vector.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Default value&lt;/b&gt;: 0.2&lt;/p&gt;  &lt;h4&gt;&lt;a name="_StillCounterThreshold"&gt;&lt;/a&gt;StillCounterThreshold&lt;/h4&gt;  &lt;p&gt;&lt;b&gt;Description&lt;/b&gt;: This parameter determines how many consecutive still vectors are required to stop a shake signal.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Default value&lt;/b&gt;: 20 (about 400 msec)&lt;/p&gt;  &lt;h4&gt;&lt;a name="_StillMagnitudeWithoutGravitationThr"&gt;&lt;/a&gt;StillMagnitudeWithoutGravitationThreshold&lt;/h4&gt;  &lt;p&gt;&lt;b&gt;Description&lt;/b&gt;: This parameter determines the maximum allowed magnitude (after reducing gravitation) for a still vector to be considered. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;Default value&lt;/b&gt;: 0.02&lt;/p&gt;  &lt;h4&gt;&lt;a name="_MaximumStillVectorsNeededForAverage"&gt;&lt;/a&gt;MaximumStillVectorsNeededForAverage&lt;/h4&gt;  &lt;p&gt;&lt;b&gt;Description&lt;/b&gt;: The maximum number of still vectors needed to create a still vector average. Instead of averaging the entire still signal, we just look at the top recent still vectors. This is performed as runtime optimization.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Default value&lt;/b&gt;: 20&lt;/p&gt;  &lt;h4&gt;&lt;a name="_MinimumStillVectorsNeededForAverage"&gt;&lt;/a&gt;MinimumStillVectorsNeededForAverage&lt;/h4&gt;  &lt;p&gt;&lt;b&gt;Description&lt;/b&gt;: The minimum number of still vectors needed to create a still vector average. Without enough vectors, the average won’t be stable and thus will be ignored.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Default value&lt;/b&gt;: 5&lt;/p&gt;  &lt;h4&gt;&lt;a name="_MinimumShakeVectorsNeededForShake"&gt;&lt;/a&gt;MinimumShakeVectorsNeededForShake&lt;/h4&gt;  &lt;p&gt;&lt;b&gt;Description&lt;/b&gt;: Determines the number of shake vectors needed in order to recognize a shake.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Default value&lt;/b&gt;: 10&lt;/p&gt;  &lt;h4&gt;&lt;a name="_WeakMagnitudeWithoutGravitationThre"&gt;&lt;/a&gt;WeakMagnitudeWithoutGravitationThreshold&lt;/h4&gt;  &lt;p&gt;&lt;b&gt;Description&lt;/b&gt;: Shake vectors with a magnitude lower than this parameter won’t be considered for gesture classification.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Default value&lt;/b&gt;: 0.2&lt;/p&gt;  &lt;h4&gt;&lt;a name="_MinimumRequiredMovesForShake"&gt;&lt;/a&gt;MinimumRequiredMovesForShake&lt;/h4&gt;  &lt;p&gt;&lt;b&gt;Description&lt;/b&gt;: Determines the number of moves required to get a shake signal.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Default value&lt;/b&gt;: 3&lt;/p&gt;  &lt;h3&gt;Summary&lt;/h3&gt;  &lt;p&gt;In this document we showed how you can use the Shake Gestures Library in your application. We did an in-depth tour of the algorithms used for recognizing shakes. Finally, we skimmed through the various parameters that you can change to better fit gesture detection to your application’s needs. &lt;/p&gt;  &lt;p&gt;Shake it up!&lt;/p&gt;  &lt;p&gt;That’s it for now,    &lt;br /&gt;Arik Poznanski.&lt;/p&gt;&lt;div class="wlWriterHeaderFooter" style="margin:0px;padding:0px 0px 0px 0px;"&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/01/shake-gestures-library-a-windows-phone-recipe.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/01/shake-gestures-library-a-windows-phone-recipe.aspx&amp;amp;bgcolor=6600FF" /&gt;&lt;/a&gt; &lt;a href="http://dotnetshoutout.com/Submit?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/01/shake-gestures-library-a-windows-phone-recipe.aspx"&gt;&lt;img alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/04/01/shake-gestures-library-a-windows-phone-recipe.aspx" style="border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=172641" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt; &lt;/div&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=815736" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Recipe/default.aspx">Recipe</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Accelerometer/default.aspx">Accelerometer</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Shake/default.aspx">Shake</category></item><item><title>Ways to Load Applications Faster – A Windows Phone Recipe</title><link>http://blogs.microsoft.co.il/blogs/arik/archive/2011/03/25/ways-to-load-applications-faster-a-windows-phone-recipe.aspx</link><pubDate>Fri, 25 Mar 2011 05:05:12 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:813930</guid><dc:creator>arik</dc:creator><slash:comments>5</slash:comments><description>&lt;p&gt;Note: the following article was first published as part of the Windows Phone Recipe “Ways to Load Applications Faster” found &lt;a href="http://create.msdn.com/en-us/education/catalog/article/Recipe_Faster_Loading_Times"&gt;here&lt;/a&gt;, which I wrote for Microsoft, together with &lt;a href="http://windowsteamblog.com/members/yochay-kiriaty/"&gt;Yochay Kiriaty&lt;/a&gt;.&lt;/p&gt;  &lt;h3&gt;Purpose of This Document&lt;/h3&gt;  &lt;p&gt;This document introduces the loading procedure for Windows Phone Silverlight applications. It explains common mistakes that application developers make during application launch, and how those errors can increase the total application load time and harm the user experience. Next, this document describes some possible solutions for overcoming long load times and explains their implementation. &lt;/p&gt;  &lt;p&gt;Application startup is also discussed in &lt;a href="http://msdn.microsoft.com/en-us/library/ff967560(v=VS.92).aspx#BKMK_Startup"&gt;Performance Considerations in Applications for Windows Phone&lt;/a&gt;. That paper provides excellent background information and can help make your Windows Phone applications shine. &lt;/p&gt;  &lt;h3&gt;Windows Phone Application Flow: Launching, Running, and Closing&lt;/h3&gt;  &lt;p&gt;We can&amp;#39;t talk about proper loading techniques and optimizing application startup time without explaining Windows Phone application lifetime events. The following section providers a short overview; for more detailed information, see &lt;a href="http://msdn.microsoft.com/en-us/library/ff769557(VS.92).aspx"&gt;Execution Model for Windows Phone&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Windows Phone provides developers with a series of events and APIs for handling tombstoning and other application state changes, which include launching and closing. The &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.shell.phoneapplicationservice(VS.92).aspx"&gt;PhoneApplicationService&lt;/a&gt; class, found in the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.shell(VS.92).aspx"&gt;Microsoft.Phone.Shell&lt;/a&gt; namespace, provides access to various aspects of the application’s lifetime, including management of the application’s state when it becomes active or inactive.&lt;/p&gt;  &lt;p&gt;The &lt;b&gt;PhoneApplicationService&lt;/b&gt; class exposes four main lifetime events. For any auto- generated Windows Phone application (generated by &lt;b&gt;Visual Studio 2010 Express for Windows Phone&lt;/b&gt; or &lt;b&gt;Visual Studio 2010&lt;/b&gt;), the &lt;b&gt;App.xaml.cs&lt;/b&gt; file includes four methods directly related to the execution model. These methods are your application handlers for the lifetime events exposed by the &lt;b&gt;PhoneApplicationService&lt;/b&gt; class:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Application_Launching &lt;/li&gt;    &lt;li&gt;Application_Activated &lt;/li&gt;    &lt;li&gt;Application_Deactivated &lt;/li&gt;    &lt;li&gt;Application_Closing &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The names of these methods are self-explanatory. However, there are some subtleties that we need to cover:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;Application Launching&lt;/b&gt; – A Windows Phone application is considered to be launched when it’s started by a means other than by the user pressing the Back button to return to a previous application. An application is launched when the user taps the entry for the application in the phone’s applications list or the tile for the application on Start. An application can also be launched when the user taps a toast notification. &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Application Deactivated&lt;/b&gt; occurs when a different application takes control of the foreground; for example, when the user launches a chooser or presses the Start button. In both cases, your application will be deactivated; the Deactivated event is raised, as opposed to the Closing event when your application exits. However, unlike an application that’s closed, a deactivated application will most likely get tombstoned. Don’t become confused: A tombstoned application’s underlying process still gets terminated, so your application does “close.” But unlike a closed application (which has exited), where the Windows Phone operating system removes any trace of the application from memory, in the deactivated scenario the Windows Phone operating system stores a record (a tombstone) of the application&amp;#39;s state. Basically, the Windows Phone operating system keeps a tombstone of the application that becomes part of the phone’s application back-stack, which is a journal that enables the use of the Back button to enhance navigation functionality. &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Application Activated&lt;/b&gt; – After an application has been deactivated, it’s possible that it will never be reactivated. However, it’s also possible that the user will return to the application by pressing the Back button enough times to reach the application. When the user returns to a deactivated application, it’s reactivated and the Activated event is raised. Windows Phone then navigates to the last page viewed by the user in order to give the user the feeling that the application is simply continuing. Note that unlike Launching, some data objects in an Activated application might still be initialized. &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Application Closing&lt;/b&gt; is simply the outcome of the user pressing the Back button enough times to navigate backwards through the pages of your application, and past the application’s first page. Currently, this is the only way for a user to exit your application. Once your application is closed, its process is terminated, the operating system removes any trace of that application from its memory, and there’s no way to return to the application other than by launching a new instance. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Note that Launching and Activated events are mutually exclusive, as are the Deactivated and Closing events.&lt;/p&gt;  &lt;p&gt;These events play a critical role in your application’s loading and closing times. Loading time also applies during application tombstoning and, more importantly, for applications resuming from tombstone.&lt;/p&gt;  &lt;p&gt;One last note before we continue. There’s a certain sequence of methods that gets called during launching and tombstoning. This method sequence is critical for optimizing load time operations. &lt;/p&gt;  &lt;p&gt;For the most part, when your application is launching or returning from tombstone, the following methods are being executed in the following order:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Application constructor –App() found in App.xaml.cs &lt;/li&gt;    &lt;li&gt;Application launching – Application_Launching found in App.xaml.cs &lt;/li&gt;    &lt;li&gt;Your application’s “first page” constructor &lt;/li&gt;    &lt;li&gt;Your application’s “first page” OnNavigatedTo method &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;Note&lt;/i&gt;&lt;/b&gt;&lt;i&gt;: When returning from tombstone, the “first page” is the last page the application was showing, and not necessarily the actual first page of the application.&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;Note:&lt;/i&gt;&lt;/b&gt;&lt;i&gt; When your application returns from a tombstone state, this entire sequence is executed. However, in cases where tombstoning is relaxed, and your application is deactivated but not tombstoned, the Application constructor and the Page constructor aren’t executed. For additional information about Application Lifetime events and tombstoning, see &lt;/i&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ff769557(VS.92).aspx"&gt;Execution Model for Windows Phone&lt;/a&gt;&lt;i&gt;.&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;Application &lt;b&gt;launch time&lt;/b&gt; is defined from the time Windows Phone loads your application into memory and starts executing the application constructor (the first method in the sequence) until the end of the execution of the OnNavigatedTo method first page. &lt;/p&gt;  &lt;h4&gt;Startup and Shutdown Times&lt;/h4&gt;  &lt;p&gt;Windows Phone enforces a series of time limits on application startup and shutdown in order to preserve a consistent and responsive user experience across the phone’s built-in applications and 3&lt;sup&gt;rd&lt;/sup&gt;-party applications. If your application exceeds the allowed time for startup or shutdown, it will be forcibly terminated and removed from the back-stack. This means your application doesn’t get tombstoned, it’s simply terminated, and the user can’t use the back button to reactivate it. The following table outlines launch shutdown, deactivated, and reactivated times:&lt;/p&gt;  &lt;p align="left"&gt;Table 1-1. Application Startup / Shutdown times &lt;/p&gt;  &lt;p align="left"&gt;   &lt;table cellspacing="0" cellpadding="0"&gt;       &lt;tr&gt;         &lt;td valign="top"&gt;           &lt;p align="left"&gt;&lt;strong&gt;Application Event&lt;/strong&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top"&gt;           &lt;p&gt;&lt;strong&gt;Limit&lt;/strong&gt;&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top"&gt;           &lt;p&gt;Starting the application (application Launching event)&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top"&gt;           &lt;p&gt;10 sec&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top"&gt;           &lt;p&gt;Forward navigating away from the application (application Deactivated event)&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top"&gt;           &lt;p&gt;10 sec&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top"&gt;           &lt;p&gt;Returning to the application using the Back key (application Activated event)&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top"&gt;           &lt;p&gt;10 sec&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top"&gt;           &lt;p&gt;Exiting from the application (application Closing event)&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top"&gt;           &lt;p&gt;10 sec&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;     &lt;/table&gt; &lt;/p&gt;  &lt;p&gt;You can see that you have up to 10 seconds of real-world time (this doesn’t mean that you have 100% of the CPU for 10 seconds) to handle each application lifetime event. If for some reason your code takes longer than 10 seconds to execute, the Windows Phone system will terminate your application. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;Note:&lt;/i&gt;&lt;/b&gt;&lt;i&gt; Besides the operating system safeguards, part of the Marketplace ingestion process is to check the time it takes to launch and to return from tombstoning. The user experience guidelines are even stricter, and require less than 10 seconds to properly launch your application. According to &lt;/i&gt;&lt;a href="http://go.microsoft.com/?linkid=9730558"&gt;&lt;i&gt;Windows Phone 7 Application Certification Requirements&lt;/i&gt;&lt;/a&gt;&lt;i&gt;, the application must render the first screen within five seconds after launch, even when there’s a splash image. Therefore, optimizing and understanding the load sequence are critical to your application’s success.&lt;/i&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;Startup time&lt;/b&gt; – Includes launching or returning to a tombstoned application. It’s the time from when your application process starts executing until your application becomes active or visible. Your application becomes visible only after the execution of the OnNavigatedTo method ends of the page the application navigates to upon launch or returning from tombstoning. Until then, the application’s splash screen is displayed and the application isn’t considered active. &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Shutdown time&lt;/b&gt; – Includes deactivating and exiting from the application, and mostly consists of the time from when the forward navigation was invoked until the Deactivated or Closing methods execution ends. &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Demonstrating the Problem&lt;/h3&gt;  &lt;p&gt;As explained in the previous section, the application must complete its loading and display its first page (or any page when returning from tombstoning) within 10 seconds or the OS will kill the process. Moreover, even if your application launches in five or eight seconds, you still need to optimize the user experience by loading the application and displaying something as soon as possible; otherwise, the impatient user might tap the Back or Windows button to navigate away from your application. &lt;/p&gt;  &lt;p&gt;So let&amp;#39;s see how easy it is to create a well-behaved application. In the following demo we’ll create a Windows Phone Silverlight application that needs to execute some long operations while loading.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;Note&lt;/i&gt;&lt;/b&gt;&lt;i&gt;: Our example application describes a very simple scenario for a Silverlight application that displays some information on the first page. This information should be obtained from some web service or local storage. To illustrate the problem, we create a fake workload that intentionally takes about 10 seconds to complete. &lt;/i&gt;&lt;/p&gt;  &lt;p&gt;To simulate a long operation, we’ll simply trigger a function that sleeps for a second and reiterate that 10 times. (See the MyService.Init methods below.)&lt;/p&gt;  &lt;p&gt;To experience this firsthand, simply follow these steps: &lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Step 1&lt;/u&gt;: Create a Windows Phone Application&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Step 2&lt;/u&gt;: Create long workloads &lt;/b&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:210e5434-9b8b-4755-9b79-5440c45e1017" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;MyService&lt;/span&gt;&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;const&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; NumberOfIterations = 10;&lt;br /&gt; &lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Init()&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; i = 0; i &amp;lt; NumberOfIterations; ++i)&lt;br /&gt;         {&lt;br /&gt;             &lt;span style="color:#2b91af;"&gt;Thread&lt;/span&gt;.Sleep(&lt;span style="color:#2b91af;"&gt;TimeSpan&lt;/span&gt;.FromSeconds(1));&lt;br /&gt;         }&lt;br /&gt;     }&lt;br /&gt; &lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Init(&lt;span style="color:#2b91af;"&gt;Dispatcher&lt;/span&gt; dispatcher)&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; i = 0; i &amp;lt; NumberOfIterations; ++i)&lt;br /&gt;         {&lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (dispatcher != &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;br /&gt;             {&lt;br /&gt;                 dispatcher.BeginInvoke(() =&amp;gt;&lt;br /&gt;                 {&lt;br /&gt;                     &lt;span style="color:#2b91af;"&gt;Thread&lt;/span&gt;.Sleep(&lt;span style="color:#2b91af;"&gt;TimeSpan&lt;/span&gt;.FromSeconds(1));&lt;br /&gt;                 });&lt;br /&gt;             }&lt;br /&gt;         }&lt;br /&gt;     }&lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Essentially, both methods perform the same operation: they sleep for about 10 seconds to mimic a long workload. The second Init method accepts a Dispatcher as an input parameter that we use each in sleep period. This forces a sync with the main user interface (UI) page (since that’s the dispatcher we’re passing in), as it isn’t reasonable to write code that completely blocks the UI thread for 10 seconds. Eventually, calling the dispatcher allows Windows Phone to terminate faster, as you’ll see later.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Step 3&lt;/u&gt;: Call the long workloads from various locations in your application&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Call the function &lt;b&gt;MyService.Init&lt;/b&gt; from either one or all five methods: &lt;/p&gt;  &lt;p&gt;1.&amp;#160; App constructor&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e9724412-2670-47de-932b-a44163352711" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;partial&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;App&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;Application&lt;/span&gt;&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; App()&lt;br /&gt;     {&lt;br /&gt;         ...&lt;br /&gt; &lt;br /&gt;         MyService.Init();&lt;br /&gt;     }&lt;br /&gt; &lt;br /&gt;     ...&lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;2.&amp;#160; Application &lt;b&gt;Launching&lt;/b&gt; event&lt;/p&gt;  &lt;p&gt;This event is raised when the user launches the application by tapping on the application’s icon.&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:867c8b36-ef58-4ef8-a84b-794d4797ace2" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;partial&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;App&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;Application&lt;/span&gt;&lt;br /&gt; {&lt;br /&gt;     ...&lt;br /&gt; &lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Application_Launching(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;LaunchingEventArgs&lt;/span&gt; e)&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#2b91af;"&gt;MyService&lt;/span&gt;.Init();&lt;br /&gt;     }&lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;3.&amp;#160; Application &lt;b&gt;Activated&lt;/b&gt; event&lt;/p&gt;  &lt;p&gt;This event is raised when the user taps the Back key to return to the application, or after returning from a chooser or a launcher.&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:63779760-057b-4ef5-b49e-6d994486f0f5" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;partial&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;App&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;Application&lt;/span&gt;&lt;br /&gt; {&lt;br /&gt;     ...&lt;br /&gt; &lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Application_Activated(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;ActivatedEventArgs&lt;/span&gt; e)&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#2b91af;"&gt;MyService&lt;/span&gt;.Init();&lt;br /&gt;     }&lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;4.&amp;#160; Page constructor &lt;/p&gt;  &lt;p&gt;This function is called when the &lt;b&gt;Page&lt;/b&gt; class is created.&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a587e019-efa2-42f9-8023-c0a4697ea71c" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;partial&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;MainPage&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;PhoneApplicationPage&lt;/span&gt;&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; MainPage()&lt;br /&gt;     {&lt;br /&gt;         InitializeComponent();&lt;br /&gt;             &lt;br /&gt;         &lt;span style="color:#2b91af;"&gt;MyService&lt;/span&gt;.Init(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.Dispatcher); &lt;span style="color:#008000;"&gt;//Or you can run MyService.Init();&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;     }&lt;br /&gt; &lt;br /&gt;     ...&lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;5.&amp;#160; Page &lt;b&gt;OnNavigatedTo&lt;/b&gt; method&lt;/p&gt;  &lt;p&gt;This function is called when the page is navigated to, either from another page or when the application gets launched/activated.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: &lt;i&gt;The problem shown in this demo also can occur when your application comes back from a tombstone state, so you need to make sure you don&amp;#39;t have lots of work in the constructor and &lt;b&gt;OnNavigatedTo&lt;/b&gt; functions of any of your pages in the application.&lt;/i&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2a29894b-7c27-4547-a7e3-3672376e3b88" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;partial&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;MainPage&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;PhoneApplicationPage&lt;/span&gt;&lt;br /&gt; {&lt;br /&gt;     ...&lt;br /&gt; &lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;override&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; OnNavigatedTo(&lt;span style="color:#2b91af;"&gt;NavigationEventArgs&lt;/span&gt; e)&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#2b91af;"&gt;MyService&lt;/span&gt;.Init(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.Dispatcher); &lt;span style="color:#008000;"&gt;//Or you can run MyService.Init();&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;     }&lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Step 4&lt;/u&gt;: Run your application&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Simply run your application from your phone and observe that the operating system terminates your application. When it terminates your application depends on specific implementation criteria, as explained below. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;Note&lt;/i&gt;&lt;/b&gt;&lt;i&gt;: To test whether the Windows Phone terminates your application when your application’s load time exceeds the 10-second limit, you must run your application on a real device &lt;u&gt;without&lt;/u&gt; attaching the debugger. You need to deploy the application to the phone and then run it. Don’t run the application from Visual Studio, as when the debugger is attached (either to your Windows Phone device or to Windows Phone emulator); the relevant watchdog timers are disabled and the application will simply load after all the fake workload methods complete their task. &lt;/i&gt;&lt;/p&gt;  &lt;p&gt;If you use the Init without the dispatcher, then the sleep (on the main UI thread) prevents any operations from executing on the main thread (which is the main application thread). This is rather extreme and doesn’t represent a real-life scenario. So we’ve added a call to the dispatcher during each sleep period in order to sync back to the UI thread, and give the Silverlight runtime a chance to do what it’s supposed to do (terminate your application). Therefore, you’ll notice that when calling the MyService.Init method without the parameter, the application will eventually get terminated, but only after all the sleep periods occur (depending on how many times you called the MyService.Init method). When you pass the dispatcher as an input param (this is only possible in the MainPage), you’ll notice that your application terminates faster. &lt;/p&gt;  &lt;p&gt;Try removing the MyService.Init method from the Application constructor and Launching method, but leave them in the MainPage constructor and OnNavigatedTo methods. You’ll see that it still takes about 11 or 12 seconds for the operating system to terminate your application. This again proves that it takes only one misbehaving method to significantly impair your application’s load time. &lt;/p&gt;  &lt;h3&gt;The Solution – Optimizing Your Application Load Time&lt;/h3&gt;  &lt;p&gt;Now that you understand the Windows Phone Silverlight application launch sequence and the problem of long launch times, it’s time to present some ways to optimize your application load times. &lt;/p&gt;  &lt;p&gt;The solution is composed of four action items:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Use a splash image &lt;/li&gt;    &lt;li&gt;Defer work &lt;/li&gt;    &lt;li&gt;Do work on a background Thread &lt;/li&gt;    &lt;li&gt;Use a loading page &lt;/li&gt; &lt;/ul&gt;  &lt;h4&gt;Action Item 1: Use a Splash Image&lt;/h4&gt;  &lt;p&gt;The first thing you can do is to help to solve the user experience issue. If the user sees an image of the application that says &amp;quot;Loading…&amp;quot;, he’ll wait a few more seconds before pressing the Back key out of frustration. Therefore, be smart and use a splash screen. &lt;/p&gt;  &lt;p&gt;In fact, all Windows Phone project templates include a splash screen image. By default, this image is named SplashScreenImage.jpg, and it automatically appears when your application is starting. The default image looks like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/image_26F11585.png"&gt;&lt;img style="margin:0px auto;display:block;float:none;" title="image" alt="image" src="http://blogs.microsoft.co.il/blogs/arik/image_thumb_4C7A92E6.png" width="220" height="366" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Make sure to change the default image to something that suits the theme of your application. That way, when users see the splash screen (which happens instantly), they’ll recognize it as part of your application. Changing the default splash screen is also a Marketplace requirement.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: The image must have:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;A size of &lt;b&gt;480 by 800&lt;/b&gt; pixels &lt;/li&gt;    &lt;li&gt;The filename set to &lt;b&gt;SplashScreenImage.jpg&lt;/b&gt; &lt;/li&gt;    &lt;li&gt;The &lt;b&gt;Build Action&lt;/b&gt; set to &lt;b&gt;Content&lt;/b&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h4&gt;Action Item 2: Defer Work&lt;/h4&gt;  &lt;p&gt;This against everything your parents taught you, but when it comes to loading an application on Windows Phone, &lt;b&gt;never do now what you can do later&lt;/b&gt;. &lt;/p&gt;  &lt;p&gt;Postponing non-mission-critical work until after the application loads is always a good technique. At that point you aren’t constrained by time issues, and you might have time to run workload between user actions. &lt;/p&gt;  &lt;p&gt;For example, suppose you write a Sudoku game for Windows Phone. You might be tempted to generate the Sudoku game map when the application loads. However, it would be best to delay this action until the application is loaded and the user selects &amp;quot;New game.&amp;quot; At this point you can show some nice animation during the game setup process.&lt;/p&gt;  &lt;p&gt;You should defer any workload that isn’t critical to the application launch and doesn’t have a severe impact on the user experience when the application loads. Always prefer lazy initialization of objects, which promotes deferring non-essential workloads. &lt;/p&gt;  &lt;p&gt;Unfortunately, not every workload in your application launch sequence can be postponed. There are certain scenarios in which you can’t defer the workload to a later time in the application or until the user performs some operation. Some scenarios require you to run a workload as close as possible to the application start time. For example, consider an application that shows the top 10 trends currently on Twitter. Without the trends information, there’s nothing real to show on the application’s main page. However, we can&amp;#39;t afford for the application to be terminated just because it’s getting the latest trends over the network.&lt;/p&gt;  &lt;p&gt;To address scenarios in which your application has to complete some work close to startup time, you need to run some or all of the workloads in the background. This is exactly what we explain in the next section. &lt;/p&gt;  &lt;h4&gt;Action Item 3: Do Work on a Background Thread&lt;/h4&gt;  &lt;p&gt;This is probably the most important step in optimizing your application load time. To keep your application from hanging or terminating, the launch methods sequence must complete as soon as possible. If you can&amp;#39;t defer a certain workload, you have to run that work in the background, that is, on a background thread. &lt;/p&gt;  &lt;p&gt;You can use the following options:&lt;/p&gt;  &lt;p&gt;&lt;b&gt;1. &lt;/b&gt;&lt;b&gt;Manually create a thread&lt;/b&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e31278a6-c275-4af5-8343-e258e190dcf4" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Threading;&lt;br /&gt; &lt;br /&gt; &lt;span style="color:#2b91af;"&gt;Thread&lt;/span&gt; thread = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Thread&lt;/span&gt;(() =&amp;gt; { &lt;span style="color:#2b91af;"&gt;MyService&lt;/span&gt;.Init(); });&lt;br /&gt; thread.Start();&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;For additional information about manually creating threads, see the &lt;a href="http://msdn.microsoft.com/en-us/library/system.threading.thread(VS.95).aspx"&gt;Thread Class&lt;/a&gt; documentation.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;2. &lt;/b&gt;&lt;b&gt;Queue work item into the thread pool&lt;/b&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f35a5346-c2ed-4567-a4a9-f364385c4ce0" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Threading;&lt;br /&gt; &lt;br /&gt; &lt;span style="color:#2b91af;"&gt;ThreadPool&lt;/span&gt;.QueueUserWorkItem((o) =&amp;gt; { &lt;span style="color:#2b91af;"&gt;MyService&lt;/span&gt;.Init(); });&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;For additional information about using the thread pool, see the &lt;a href="http://msdn.microsoft.com/en-us/library/system.threading.threadpool(VS.95).aspx"&gt;ThreadPool Class&lt;/a&gt; documentation. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;3. &lt;/b&gt;&lt;b&gt;Use BackgroundWorker class&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;By using the BackgroundWorker class, you can assign a delegate that will perform the workload, as well as a callback method that will be executed once the delegate completes its operation. &lt;/p&gt;  &lt;p&gt;To use the &lt;b&gt;BackgroundWorker&lt;/b&gt; class, you’ll need to add a using statement for System.ComponentModel. &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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1760dab1-2903-4d56-92aa-51e8d464d6b0" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.ComponentModel;&lt;br /&gt; &lt;br /&gt; &lt;span style="color:#2b91af;"&gt;BackgroundWorker&lt;/span&gt; backgroundWorker = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;BackgroundWorker&lt;/span&gt;(); &lt;br /&gt; &lt;br /&gt; backgroundWorker.DoWork += &lt;br /&gt;     (s,e) =&amp;gt; &lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#008000;"&gt;// runs on background thread&lt;/span&gt;&lt;br /&gt;         &lt;span style="color:#2b91af;"&gt;MyService&lt;/span&gt;.Init(); &lt;br /&gt;     };&lt;br /&gt; &lt;br /&gt; backgroundWorker.RunWorkerCompleted +=&lt;br /&gt;     (s, e) =&amp;gt;&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#008000;"&gt;// runs on UI thread        &lt;/span&gt;&lt;br /&gt;     };&lt;br /&gt; &lt;br /&gt; backgroundWorker.RunWorkerAsync();&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;For additional information about using the BackgroundWorker class, see the &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker(VS.95).aspx"&gt;BackGroundWorker Class&lt;/a&gt; documentation &lt;/p&gt;  &lt;p&gt;When working with a background thread, you can’t directly update any UI control without marshaling to the UI thread from your back-thread. Silverlight offers a simple mechanism to do that by using the &lt;b&gt;Dispatcher.BegineInvoke&lt;/b&gt; method.&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e7a75149-8181-4b39-ab41-b5585770d91b" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#2b91af;"&gt;Deployment&lt;/span&gt;.Current.Dispatcher.BeginInvoke(() =&amp;gt;&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color:#008000;"&gt;//This happens on UI thread, if you want to marshal info back to UI thread from any other background thread.&lt;/span&gt;&lt;br /&gt; });&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;Note:&lt;/i&gt;&lt;/b&gt;&lt;i&gt; When working with background threads, you should always remember that UI components in Silverlight have thread affinity; that is, you can access a control only from the thread that created the control. So if you need to update the UI with progress/completed reports from the background thread, you should dispatch your code to run on the correct thread. This can be done by using the method &lt;b&gt;myControl.Dispatcher.BeginInvoke()&lt;/b&gt;, where myControl is the control you want to update.&lt;/i&gt;&lt;/p&gt;  &lt;h4&gt;Action Item 4: Use a Loading Page&lt;/h4&gt;  &lt;p&gt;Now that you’ve moved some of the workload to the background, your application will load much faster and you should see your application’s first page rather quickly. However, most likely you’ve got nothing meaningful (such as the new data you’re fetching) to show, since the background thread is still executing. Therefore, If you started some work on a background thread , you should consider showing a busy/loading indicator, like a progress bar, during the wait time.&lt;/p&gt;  &lt;p&gt;You should avoid having a separate page for the loading indicator UI, since it would become part of the application’s page back stack. This would create a strange scenario in which pressing the Back button from the main page would return the user to the loading page rather than exiting the app. &lt;/p&gt;  &lt;p&gt;Instead, in your main page, add a grid that contains two controls: the “loading control” that will show loading information (indicator), and the actual main page content. Toggle the &lt;b&gt;Visibility&lt;/b&gt; property of the two controls according to the current loading state. Also, if you set the ProgressBar’s IsIndeterminate property to true , &lt;i&gt;turn it off&lt;/i&gt; once you no longer need the loading screen, or you’ll have performance issues. You can read more about this at &lt;a href="http://blogs.microsoft.co.il/blogs/arik/archive/2011/01/27/a-progressbar-with-text-for-windows-phone-7.aspx"&gt;A ProgressBar With Text For Windows Phone 7&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;For example, the following XAML shows how a main page could be structured:&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d345a698-f2c8-4572-940c-4667bf87714d" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;ContentPanel&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;12,0,12,0&amp;quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;loadingContent&amp;quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;         &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt; &lt;br /&gt;            &lt;span style="color:#ff0000;"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#ff0000;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0,-30,0,0&amp;quot;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Loading...&amp;quot;&lt;/span&gt; &lt;br /&gt;            &lt;span style="color:#0000ff;"&gt; /&amp;gt;&lt;/span&gt;&lt;br /&gt;         &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ProgressBar&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;progressBar&amp;quot;&lt;/span&gt; &lt;br /&gt;            &lt;span style="color:#ff0000;"&gt; Minimum&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0&amp;quot;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#ff0000;"&gt; Maximum&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;100&amp;quot;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt; /&amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;mainPageContent&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Visibility&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Collapsed&amp;quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;         &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt; &lt;br /&gt;            &lt;span style="color:#ff0000;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#ff0000;"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt; &lt;br /&gt;            &lt;span style="color:#ff0000;"&gt; FontSize&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;56&amp;quot;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Main page data&amp;quot;&lt;/span&gt; &lt;br /&gt;            &lt;span style="color:#0000ff;"&gt; /&amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The following code shows how to use the BackgroundWorker class to do the work in the background, update the progress bar, and toggle &lt;b&gt;Visibility&lt;/b&gt; when the work’s done:&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9969a829-b671-4035-b249-97dd946a5fdf" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#2b91af;"&gt;MyService&lt;/span&gt;.BackgroundWorker = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;BackgroundWorker&lt;/span&gt;()&lt;br /&gt; {&lt;br /&gt;     WorkerReportsProgress = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;&lt;br /&gt; };&lt;br /&gt; &lt;br /&gt; &lt;span style="color:#2b91af;"&gt;MyService&lt;/span&gt;.BackgroundWorker.DoWork +=&lt;br /&gt;     (s, e) =&amp;gt;&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#2b91af;"&gt;MyService&lt;/span&gt;.Init();&lt;br /&gt;     };&lt;br /&gt; &lt;br /&gt; &lt;span style="color:#2b91af;"&gt;MyService&lt;/span&gt;.BackgroundWorker.ProgressChanged +=&lt;br /&gt;     (s, e) =&amp;gt;&lt;br /&gt;     {&lt;br /&gt;         progressBar.Value = e.ProgressPercentage;&lt;br /&gt;     };&lt;br /&gt; &lt;br /&gt; &lt;span style="color:#2b91af;"&gt;MyService&lt;/span&gt;.BackgroundWorker.RunWorkerCompleted +=&lt;br /&gt;     (s, e) =&amp;gt;&lt;br /&gt;     {&lt;br /&gt;         loadingContent.Visibility = &lt;span style="color:#2b91af;"&gt;Visibility&lt;/span&gt;.Collapsed;&lt;br /&gt;         mainPageContent.Visibility = &lt;span style="color:#2b91af;"&gt;Visibility&lt;/span&gt;.Visible;&lt;br /&gt;     };&lt;br /&gt; &lt;br /&gt; &lt;span style="color:#2b91af;"&gt;MyService&lt;/span&gt;.BackgroundWorker.RunWorkerAsync();&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;In order to receive progress updates from the background thread, we passed the &lt;b&gt;BackgroundWorker&lt;/b&gt; to &lt;b&gt;MyService&lt;/b&gt; class, and use the &lt;b&gt;ReportProgress&lt;/b&gt; method:&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5e8db11b-a39a-4b38-9c5c-600230ca85c7" class="wlWriterSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;MyService&lt;/span&gt;&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;const&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; NumberOfIterations = 10;&lt;br /&gt; &lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;BackgroundWorker&lt;/span&gt; BackgroundWorker { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;br /&gt; &lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Init()&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; i = 0; i &amp;lt; NumberOfIterations; ++i)&lt;br /&gt;         {&lt;br /&gt;             &lt;span style="color:#2b91af;"&gt;Thread&lt;/span&gt;.Sleep(&lt;span style="color:#2b91af;"&gt;TimeSpan&lt;/span&gt;.FromSeconds(1));&lt;br /&gt; &lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (BackgroundWorker != &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;br /&gt;             {&lt;br /&gt;                 BackgroundWorker.ReportProgress((i+1) * 100 / NumberOfIterations);&lt;br /&gt;             }&lt;br /&gt;         }&lt;br /&gt;     }&lt;br /&gt; &lt;br /&gt;     ...&lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Another way to toggle between the controls is to bind the &lt;b&gt;Visibility&lt;/b&gt; property of both the &lt;b&gt;mainContent&lt;/b&gt; and &lt;b&gt;loadingContent &lt;/b&gt;to a Boolean flag that signifies the loading state (for example, bool isLoading). To do that, you’ll need a class that implements &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter(VS.95).aspx"&gt;IValueConverter&lt;/a&gt; to convert from bool to &lt;b&gt;Visibility&lt;/b&gt;.&lt;/p&gt;  &lt;h3&gt;Summary&lt;/h3&gt;  &lt;p&gt;Windows Phone applications must load fast and provide a good user experience. This is enforced by the application certification process and by the operating system. While the sample provided in this article is rather simple, the concepts remain true for all Windows Phone applications, and the techniques explained here will work for any Windows Phone application. &lt;/p&gt;  &lt;p&gt;Another important consideration is the actual versus the perceived user experience. There’s more than one way to show loading progress, other than a progress bar, but it’s important to show something that’s meaningful and tells the user,“Hey, soon you’ll see your favorite app.” &lt;/p&gt;  &lt;p&gt;That’s it for now,    &lt;br /&gt;Arik Poznanski.&lt;/p&gt;&lt;div class="wlWriterHeaderFooter" style="margin:0px;padding:0px 0px 0px 0px;"&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/03/25/ways-to-load-applications-faster-a-windows-phone-recipe.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/03/25/ways-to-load-applications-faster-a-windows-phone-recipe.aspx&amp;amp;bgcolor=6600FF" /&gt;&lt;/a&gt; &lt;a href="http://dotnetshoutout.com/Submit?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/03/25/ways-to-load-applications-faster-a-windows-phone-recipe.aspx"&gt;&lt;img alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/03/25/ways-to-load-applications-faster-a-windows-phone-recipe.aspx" style="border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=172641" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt; &lt;/div&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=813930" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Performance/default.aspx">Performance</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Threads/default.aspx">Threads</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Application+Loading/default.aspx">Application Loading</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Recipe/default.aspx">Recipe</category></item><item><title>3-Screens Development using WPF, SL and WP7 - SDP 2011 Conference</title><link>http://blogs.microsoft.co.il/blogs/arik/archive/2011/03/16/3-screens-development-using-wpf-sl-and-wp7-sdp-2011-conference.aspx</link><pubDate>Wed, 16 Mar 2011 17:59:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:806885</guid><dc:creator>arik</dc:creator><slash:comments>3</slash:comments><description>&lt;div style="PADDING-BOTTOM:4px;MARGIN:0px;PADDING-LEFT:0px;PADDING-RIGHT:0px;FLOAT:none;PADDING-TOP:4px;" class="wlWriterHeaderFooter"&gt;&lt;iframe style="BORDER-BOTTOM:medium none;BORDER-LEFT:medium none;WIDTH:130px;HEIGHT:80px;BORDER-TOP:medium none;BORDER-RIGHT:medium none;" src="http://www.facebook.com/widgets/like.php?href=http://blogs.microsoft.co.il/blogs/arik/archive/2011/03/16/3-screens-development-using-wpf-sl-and-wp7-sdp-2011-conference.aspx" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;p&gt;Yesterday I’ve delivered my lecture titled “&lt;strong&gt;3-Screens Development using WPF, SL and WP7&lt;/strong&gt;” in the SDP 2011 conference.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/arik/197389_201361109891595_184255348268838_680237_2957281_n_2EDA2E11.jpg"&gt;&lt;img style="MARGIN:0px auto;DISPLAY:block;FLOAT:none;" title="197389_201361109891595_184255348268838_680237_2957281_n" alt="197389_201361109891595_184255348268838_680237_2957281_n" src="http://blogs.microsoft.co.il/blogs/arik/197389_201361109891595_184255348268838_680237_2957281_n_thumb_4F5147F6.jpg" width="720" height="540" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In this lecture I’ve presented the application &lt;a href="http://code.msdn.microsoft.com/FlashCards"&gt;FlashCards.Show&lt;/a&gt;&lt;strong&gt; &lt;/strong&gt;which has 3 clients in WPF, Silverlight and Windows Phone 7.&lt;/p&gt;
&lt;p&gt;I showed how to share the code base between the different clients using: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;MVVM &lt;/li&gt;
&lt;li&gt;Adding files as links &lt;/li&gt;
&lt;li&gt;Preprocessor symbols &lt;/li&gt;
&lt;li&gt;OOP &lt;/li&gt;
&lt;li&gt;Portable Library tools &lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Then I showed a few features that exist in WPF and don’t exist in Silverlight, and how one can overcome this gap.&lt;/p&gt;
&lt;p&gt;Specifically I showed how to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Implement &lt;strong&gt;Commands&lt;/strong&gt; in Silverlight 3 &lt;/li&gt;
&lt;li&gt;Implement &lt;strong&gt;ClipToBounds&lt;/strong&gt; property &lt;/li&gt;
&lt;li&gt;Implement a &lt;strong&gt;DataTemplateSelector&lt;/strong&gt; replacement &lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;I want to thank all the people who came to my lecture today. &lt;br /&gt;I really enjoyed it and I hope you too.&lt;/p&gt;
&lt;p&gt;You can download the PowerPoint presentation and the demos &lt;a href="http://cid-552e8ea12a93deba.office.live.com/browse.aspx/.Public?uc=1"&gt;here&lt;/a&gt;&lt;strong&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In addition you can find more references on porting from WPF to Silverlight in the following posts:&lt;/p&gt;
&lt;p&gt;&lt;a title="Porting from WPF to Silverlight- The Missing Pieces, Part 1" href="http://blogs.microsoft.co.il/blogs/arik/archive/2010/09/21/porting-from-wpf-to-silverlight-the-missing-pieces-part-1.aspx"&gt;Porting from WPF to Silverlight- The Missing Pieces, Part 1&lt;/a&gt; &lt;br /&gt;&lt;a title="Porting from WPF to Silverlight- The Missing Pieces, Part 2" href="http://blogs.microsoft.co.il/blogs/arik/archive/2010/09/23/porting-from-wpf-to-silverlight-the-missing-pieces-part-2.aspx"&gt;Porting from WPF to Silverlight- The Missing Pieces, Part 2&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I will post again when my lecture will be available to view on &lt;a href="http://scc.sela.co.il/scc"&gt;Sela College Channel&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;That’s it for now, &lt;br /&gt;Arik Poznanski.&lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=806885" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Sela/default.aspx">Sela</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+Azure/default.aspx">Windows Azure</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/SDP/default.aspx">SDP</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/SDP+2011/default.aspx">SDP 2011</category></item><item><title>Flashcards.Show – Planning a Cross-Platform Solution</title><link>http://blogs.microsoft.co.il/blogs/arik/archive/2011/03/13/flashcards-show-planning-a-cross-platform-solution.aspx</link><pubDate>Sun, 13 Mar 2011 23:02:11 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:805807</guid><dc:creator>arik</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Following is another post by &lt;a href="http://windowsteamblog.com/members/yochay-kiriaty/"&gt;Yochay Kiriaty&lt;/a&gt; on a project I’ve done for Microsoft involving WPF, Silverlight, Windows Phone 7 and Windows Azure.&lt;/p&gt;  &lt;p&gt;If you’re interested in more details, make sure you come to my presentation at the coming &lt;a href="http://www.sela.co.il//s/sdp/_new/practice2011.html"&gt;SDP 2011&lt;/a&gt; conference (in two days!).&lt;/p&gt;  &lt;p&gt;[Cross-posted from &lt;a title="http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/03/03/flashcards-show-planning-a-cross-platform-solution.aspx" href="http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/03/03/flashcards-show-planning-a-cross-platform-solution.aspx"&gt;http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/03/03/flashcards-show-planning-a-cross-platform-solution.aspx&lt;/a&gt;]&lt;/p&gt;  &lt;p&gt;I recently blogged about &lt;a href="http://windowsteamblog.com/windows/b/developers/archive/2011/02/17/flashcards-show-version-2-for-the-desktop-browser-and-windows-phone.aspx"&gt;Flashcards.Show Version 2 for WPF, Silverlight, and Windows Phone&lt;/a&gt;, which features the Flashcards.Show application. I’m not going to (again) review the app, but I do want to talk about how we developed the application and the design the code base to support multiple clients. &lt;/p&gt;  &lt;p&gt;The first version of Flashcards.Show was a Windows (WPF) application. This app was originally designed by &lt;a href="http://www.identitymine.com/forward/2011/02/identitymines-flashcards-show-application-easily-updated-by-yochayk-and-arikpoz/"&gt;IdentityMine&lt;/a&gt;, and used a few Windows 7 features such as multi-touch and taskbar integration. While the first version was great, we wanted to increase its value by enabling users to share the decks that they are creating. Therefore, when we set to work on version 2, we sought both functional and technological solutions to enable ease of use for the deck-sharing scenarios, as well as ease of development and maintenance of the code. &lt;/p&gt;  &lt;p&gt;Ease of use for a deck-sharing scenario is achieved by enabling users to simply click one button to start the sharing process, and another to send the deck. Behind the scenes, the application communicates with Windows Azure Flashcards services and uploads the deck. To keep it simple, we chose to use the default email client application as the means for sending the email. The pre-populated email that is generated includes a link to a Silverlight player that lets the email recipients view and interact with the attached deck. If you want to experience it first hand, you can try by &lt;a href="http://flashcardsshow.cloudapp.net:81/FlashCards.UI.SL.html?param=bTVkemgxYWxtYQ"&gt;clicking this link&lt;/a&gt;. The email also includes information on how to download the deck to your Windows Phone application and how to install (using ClickOnce) the WPF application.&lt;/p&gt;  &lt;p&gt;&lt;img style="display:block;float:none;margin-left:auto;margin-right:auto;" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-53-84-metablogapi/1411.image_5F00_1891AC3E.png" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Sharing Code between WPF, Silverlight and Windows Phone&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;After we designed deck sharing, our next step was to build the Silverlight viewer. We knew that we were going to target Windows Phone as the next platform, and therefore our first decision was to make sure the runtimes are compatible. This drove the decision to build the viewer as a Silverlight 3 rather than Silverlight 4 application. While this decision costs us a few days of hard work to implement SL4 features in SL3 code, it paid off during the Windows Phone development phase. &lt;/p&gt;  &lt;p&gt;The second decision was to share as much code base as possible, which we did. The &lt;a href="http://code.msdn.microsoft.com/FlashcardsShow-84f2b3ba"&gt;Flashcards.Show source code&lt;/a&gt; includes a solution file that includes all the “client” (WPF, Silverlight, and Windows Phone) projects. If you’re interested, you can find another solution file that includes all Flashcards.Show projects, including Windows Azure in the &lt;b&gt;WindowsAzureService&lt;/b&gt; folder (once you extract the zip file). . For now, we’ll focus on the client projects:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;FlashCards.ViewModel.WPF&lt;/b&gt; – Contains the View-Model piece of the MVVM architecture that is used in the Windows application &lt;/li&gt;    &lt;li&gt;&lt;b&gt;FlashCards.ViewModel.SL&lt;/b&gt; – Contains the View-Model piece of the MVVM architecture that is used in the Silverlight application &lt;/li&gt;    &lt;li&gt;&lt;b&gt;FlashCards.ViewModel.Phone&lt;/b&gt; – Contains the View-Model piece of the MVVM architecture that is used in the Windows Phone application &lt;/li&gt;    &lt;li&gt;&lt;b&gt;FlashCards.UI.WPF&lt;/b&gt; – Contains the main Windows application, including both modes, Admin and Game&lt;b&gt; &lt;/b&gt;&lt;/li&gt;    &lt;li&gt;&lt;b&gt;FlashCards.UI.SL&lt;/b&gt; – Contains the Silverlight application, including the different pages and resources &lt;/li&gt;    &lt;li&gt;&lt;b&gt;FlashCards.UI.Phone&lt;/b&gt; – Contains the Windows Phone application, including the different pages and resources &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Looking at the above list, you might be asking yourself if there are duplications between the different ViewModel projects and the UI projects. To start with, we have to compile for the target framework. The assembly that is used for WPF ViewModel .NET 3.5 is not supported by Silverlight or Windows Phone. In addition to the Silverlight assembly, Silverlight 3 also is not fully supported by Windows Phone. Therefore you have no other option but to compile to the required target CLR. &lt;/p&gt;  &lt;p&gt;But there is more to it than this, especially in regard to the ViewModel project. Since all clients basically share the same data model, they all have the same application logic, display the same games, and follow the same game rules. Therefore both the Silverlight and Windows Phone view-model projects include links to most of the &lt;b&gt;FlashCards.ViewModel.WPF&lt;/b&gt; view-model project. The WPF view-model contains the data model for the deck of cards (&lt;b&gt;cardDeck.cs&lt;/b&gt;), which is comprised of individual cards (&lt;b&gt;cardPair.cs&lt;/b&gt;), which again are comprised of two sides of a card (&lt;b&gt;card.cs&lt;/b&gt;). The model includes metadata (MetaData) information about the types of items (text, image, sound, video, URL) placed on each card. The games logic is also part of the view-model as you can see in the LearningGameViewModel.cs and the MatchingGameViewModel.cs. Feel free to further explore the code. &lt;/p&gt;  &lt;p&gt;If you review the &lt;b&gt;Flashcards.ViewModel.SL&lt;/b&gt; and &lt;b&gt;Flashcards.ViewModel.Phone&lt;/b&gt; projects, you’ll see that they are &lt;b&gt;virtually&lt;/b&gt; identical, and the code files in each of these projects simply contain &lt;b&gt;links&lt;/b&gt; to the original WPF view-model files. &lt;/p&gt;  &lt;p&gt;However, a more careful review of the &lt;b&gt;Flashcards.ViewModel.SL&lt;/b&gt; reveals some differences. For example, the Silverlight view-model doesn’t have the &lt;b&gt;Taskbar.cs&lt;/b&gt; file, since it doesn’t integrate with the Windows 7 taskbar as the WPF application does. The Silverlight version also doesn’t include the &lt;b&gt;DeckPackaging.cs&lt;/b&gt; file, since we don’t allow the Silverlight viewer to edit and upload decks to the Windows Azure service. &lt;/p&gt;  &lt;p&gt;We omit files and classes of features that are not functional in the Silverlight and Windows Phone solutions. You might want to note that the &lt;b&gt;Flashcards.ViewModel.Phone&lt;/b&gt; is identical to the Silverlight view-model. &lt;/p&gt;  &lt;p&gt;But there are additional changes that reflect the differences between the different platforms. In the view-model projects, you can find them in the &lt;b&gt;MainViewModel&lt;/b&gt;.cs file. The WPF and Silverlight versions of this file are quite different from each other. The Windows Phone code is embedded into the Silverlight project and we use WINDOWS_PHONE and SILVERLIGHT conditional compile time symbols to distinguish between the two. Reviewing the &lt;b&gt;MainViewModel.cs&lt;/b&gt; file, you’ll notice compile time conditional statements such as: #if WINDOWS_PHONE&lt;/p&gt;  &lt;p&gt;The reason we decided to use compile time symbols instead of creating a complete new copy of the &lt;b&gt;MainViewModel.cs&lt;/b&gt; file in the phone project is due to the simple fact that while there are differences between the two, they are small and relatively easily encapsulated. &lt;/p&gt;  &lt;p&gt;For example, the Windows Phone application can save decks in local store, a feature we are not using in Silverlight (although possible). This introduces a completely new set of features, like getting a deck from isolated storage over the network, which can be encapsulated for the Windows Phone implementation, and abstracted from the main view-model logic. We simply make sure the main view-model receives the required information for its internal data model, and when the code compiles and runs on Windows Phone, we make sure we wrap the additional functionality in such a way that it is transparent to the main view-model logic. &lt;/p&gt;  &lt;p&gt;For example, the &lt;b&gt;StartLoading&lt;/b&gt; function is implemented for Silverlight and Windows Phone. While the code is similar in nature, In the Windows Phone implementation you’ll notice that we need to jump through extra hoops. For example, in the &lt;b&gt;webClient_OpenReadCompleted&lt;/b&gt; method (called…), we don’t just return a stream back to the view-model, we also write the deck to the isolated storage. During the write time, we show a progress report, because such operations on a Windows Phone can take some time. &lt;/p&gt;  &lt;p&gt;Another example is the private &lt;b&gt;_instance_PropertyChanged &lt;/b&gt;method that is used in Windows Phone to control the navigation between the application pages, where in the Silverlight version we simply swap in and out user controls instead of complete pages. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;Lesson Learned &lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Make your data model technology-agnostic as possible &lt;/li&gt;    &lt;li&gt;In your view-model, separate the way you handle data (the model) and the flow (screen, pages, etc.) of the application (the view) within your application logic. This will make it easier to introduce different behaviors and code for different platforms, just as we did for Windows Phone and SL &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;b&gt;Sharing UI (XAML) Is Difficult&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;This brings us to the next topic of sharing UI and XAML. While sharing the View-Model is relatively straightforward, sharing the UI, is a completely different story. &lt;/p&gt;  &lt;p&gt;To start with, there is no #if def support for XAML. Therefore, you can’t use compile time symbols to control which XAML code end up in which project. Next, the namespaces are different. WPF uses a &lt;b&gt;System.Windows.Window&lt;/b&gt;, whereas Silverlight uses &lt;b&gt;System.Windows.Controls.UserControl&lt;/b&gt;. But even if you successfully overcome the namespace problem, there is a bunch of functionality in WPF4 that is not in Silverlight 3 (remember we chose SL3 for ease of migration to Windows Phone). Therefore, we end up rewriting most of the Silverlight application. With that said, you can still leverage all of your .NET and WPF skills as you write the Silverlight XAML, using data binding, date templates, and such. However, I really hope Shawn’s work on &lt;a href="http://blogs.msdn.com/b/sburke/archive/2011/01/23/3-screen-coding-is-here-portable-library-tools-allow-you-to-target-multiple-net-platforms-with-one-binary.aspx"&gt;3-Screen Coding Is Here: Portable Library Tools allow you to target multiple .NET platforms with one binary&lt;/a&gt; will help reduce such friction in the near future. &lt;/p&gt;  &lt;p&gt;While converting the WPF solutions to support Silverlight 3 was a pain, we deliberately targeted Silverlight 3 and not Silverlight 4 because Windows Phone Silverlight runtime is version 3. The reason is simple; we wanted the easiest possible port from Silverlight to Windows Phone. And the outcome was just that, a super easy port from Silverlight to Windows Phone. It took about &lt;b&gt;3 days&lt;/b&gt; to make the Silverlight application run on Windows Phone.&lt;/p&gt;  &lt;p&gt;If you look at the &lt;b&gt;FlashCards.UI.Phone&lt;/b&gt; project, you’ll find that most of the files are links to the Silverlight UI project. The differences are visible when we check the displaying screens. In Windows Phone Silverlight application there is only one way to display data – inside a Windows Phone Page. Therefore the Windows Phone and Silverlight solutions differ in that way. But even here, the Silverlight and Windows Phone versions are very similar. &lt;/p&gt;  &lt;p&gt;For example, the Windows Phone &lt;b&gt;LearningPage.xaml&lt;/b&gt; includes a &lt;b&gt;LearningGame &lt;/b&gt;user control (LearningGame.xaml). If you look at the Silverlight &lt;b&gt;LearningGame.XAML,&lt;/b&gt; you’ll find the same user control. While we had to copy the XAML file and make &lt;b&gt;some&lt;/b&gt; changes to fit the smaller screen, the core of the control, its behavior, and the code behind are very (very) similar. Therefore, even if we did end up copying XAML files, the core functionality remains the same. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;Lessons Learned &lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Unfortunately, we can’t really share XAML code &lt;/li&gt;    &lt;li&gt;Some controls can be reused &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;b&gt;Bottom Line&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Obviously, there is no single silver bullet solution to sharing code across multiple platforms. With that said, while working on this project, we learned that there is a lot of room to navigate the platform’s limitations.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Using MVVM in your WPF/SL solution makes it easier to share the model. Your application data models, logic and any request to the server side backend can and should be shared. &lt;/li&gt;    &lt;li&gt;As for your UI, well, that really depends on the complexity of your design, and how closely you want your implementation to be dependent upon the platform form factor, like the phone’s small screen. However, even here there is some flexibility. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;You are more than welcome to &lt;a href="http://code.msdn.microsoft.com/FlashcardsShow-84f2b3ba"&gt;download&lt;/a&gt; the project source code, which includes some documentation. And please &lt;a href="http://channel9.msdn.com/posts/FlashcardsShow-Version-2-running-on-Windows-Phone-and-IE"&gt;watch&lt;/a&gt; a short video on C9 demoing the 3 client applications. As usual, your feedback is most welcome. &lt;/p&gt;  &lt;p&gt;&lt;object type="application/x-silverlight-2" data="data:application/x-silverlight-2," width="512" height="288"&gt;&lt;param name="minRuntimeVersion" value="4.0.50401.0" /&gt;&lt;param name="source" value="http://channel9.msdn.com/scripts/Channel9.xap?v=1.5" /&gt;&lt;param name="initParams" value="mediaurl=http://media.ch9.ms/ch9/b72d/74f823fb-b458-47a6-b024-9e8c0143b72d/FlashcardsShow_ch9.wmv,thumbnail=http://media.ch9.ms/ch9/b72d/74f823fb-b458-47a6-b024-9e8c0143b72d/FlashcardsShow_512_ch9.jpg,deliverymethod=progressivedownload,autoplay=false,entryid=74f823fbb45847a6b0249e8c0143b72d" /&gt;&lt;/object&gt;&lt;/p&gt;  &lt;p&gt;I want to thank &lt;a href="http://blogs.microsoft.co.il/blogs/arik/"&gt;Arik Poznanski&lt;/a&gt;, from Sela group, who helped drive the second phase of Flashcards.show.&lt;/p&gt;  &lt;p&gt;Follow Windows Phone announcements on Twitter at &lt;a href="http://twitter.com/wp7dev"&gt;WP7DEV&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Follow &lt;a href="http://twitter.com/yochayk"&gt;Yochay on Twitter&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Get &lt;a href="http://create.msdn.com/en-US/"&gt;started&lt;/a&gt; with &lt;a href="http://create.msdn.com/en-us/home/getting_started"&gt;free tools&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/wp7trainingcourse.aspx"&gt;free training&lt;/a&gt;, and &lt;a href="http://windowsteamblog.com/windows_phone/b/wpdev/archive/2010/08/17/windows-phone-7-jump-start-training.aspx"&gt;free Jump Start video course&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;(Post edited by Barbara Alban)&lt;/p&gt;  &lt;p&gt;[end of cross-post]&lt;/p&gt;  &lt;p&gt;That’s it for now,    &lt;br /&gt;Arik Poznanski&lt;/p&gt;&lt;div class="wlWriterHeaderFooter" style="margin:0px;padding:0px 0px 0px 0px;"&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/03/13/flashcards-show-planning-a-cross-platform-solution.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/03/13/flashcards-show-planning-a-cross-platform-solution.aspx&amp;amp;bgcolor=6600FF" /&gt;&lt;/a&gt; &lt;a href="http://dotnetshoutout.com/Submit?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/03/13/flashcards-show-planning-a-cross-platform-solution.aspx"&gt;&lt;img alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/03/13/flashcards-show-planning-a-cross-platform-solution.aspx" style="border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=172641" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt; &lt;/div&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=805807" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+Azure/default.aspx">Windows Azure</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/SDP/default.aspx">SDP</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/FlashCards.Show/default.aspx">FlashCards.Show</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Azure/default.aspx">Azure</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/SDP+2011/default.aspx">SDP 2011</category></item><item><title>Flashcards.Show Version 2 for the Desktop, Browser, and Windows Phone</title><link>http://blogs.microsoft.co.il/blogs/arik/archive/2011/03/04/flashcards-show-version-2-for-the-desktop-browser-and-windows-phone.aspx</link><pubDate>Fri, 04 Mar 2011 21:15:38 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:801071</guid><dc:creator>arik</dc:creator><slash:comments>4</slash:comments><description>&lt;p&gt;Following is a great post by &lt;a href="http://windowsteamblog.com/members/yochay-kiriaty/"&gt;Yochay Kiriaty&lt;/a&gt; on a project I’ve done involving WPF, Silverlight, Windows Phone 7 and Windows Azure.&lt;/p&gt;  &lt;p&gt;If you’re interested in more details, make sure you come to my presentation at the coming &lt;a href="http://www.sela.co.il//s/sdp/_new/practice2011.html"&gt;SDP 2011&lt;/a&gt; conference.&lt;/p&gt;  &lt;p&gt;[Cross-posted from &lt;a title="http://windowsteamblog.com/windows/b/developers/archive/2011/02/17/flashcards-show-version-2-for-the-desktop-browser-and-windows-phone.aspx" href="http://windowsteamblog.com/windows/b/developers/archive/2011/02/17/flashcards-show-version-2-for-the-desktop-browser-and-windows-phone.aspx"&gt;http://windowsteamblog.com/windows/b/developers/archive/2011/02/17/flashcards-show-version-2-for-the-desktop-browser-and-windows-phone.aspx&lt;/a&gt;]&lt;/p&gt;  &lt;p&gt;&lt;img style="display:block;float:none;margin-left:auto;margin-right:auto;" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-53-70-metablogapi/1884.image_5F00_7B944EBB.png" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;The Flashcards.show application has been around for few months now. It is mostly used as a developer’s reference and demo for showing specific and cool Windows 7 features. While the first version of the Flashcards let you create all kinds of decks and then consume these cards in the form of games, you could not share any of the great cards you created with anyone else except by sending the deck file itself via email..&lt;/p&gt;  &lt;p&gt;&lt;img style="display:block;float:none;margin-left:auto;margin-right:auto;" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-53-70-metablogapi/3566.image_5F00_322E69C9.png" alt="" /&gt;&lt;/p&gt;  &lt;p align="center"&gt;Figure 1: Flashcards.Show in “Game” mode&lt;/p&gt;  &lt;p&gt;With that in mind, we started working on Flashcards.Show &lt;strong&gt;version 2&lt;/strong&gt;. Our goal was to enable seamless and easy sharing of decks among users across different computers. The idea was simple, upload the deck to the cloud, and let the user send a message to whomever the user wants to share the deck with. That message will include a link for the receiving party to click on to launch a web browser and run a Silverlight application that can “play” the shared deck. The Silverlight application dynamically downloads the shared deck and displays that single deck just as it would be displayed on the WPF application. At this point the user can launch any of the 3 games: Learning, Matching, or Memory, with the same user experience as the WPF application. &lt;/p&gt;  &lt;p&gt;&lt;img style="display:block;float:none;margin-left:auto;margin-right:auto;" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-53-70-metablogapi/4744.image_5F00_05A539E3.png" alt="" /&gt;&lt;/p&gt;  &lt;p align="center"&gt;Figure 2: Flashcards.Show memory game running in IE as Silverlight application&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;Note&lt;/i&gt;&lt;/b&gt;&lt;i&gt;: The shared decks have a few limitations. The deck size can’t exceed 5MB and we don’t allow video or audio. All restrictions are functional and not technical. We didn’t want to get into too deep of a development cycle. &lt;/i&gt;&lt;/p&gt;  &lt;p&gt;So far so good, we have a WPF application that can share decks through the cloud and a Silverlight application that can play these decks. The next logical step was to try and run the Silverlight application on Windows Phone. Since one of Windows Phone development models is Silverlight, there is a good chance the app will run. So we tried. As you can see it works!&lt;/p&gt;  &lt;p&gt;&lt;img style="display:block;float:none;margin-left:auto;margin-right:auto;" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-53-70-metablogapi/0574.image_5F00_274162B4.png" alt="" /&gt;&lt;/p&gt;  &lt;p align="center"&gt;Figure 3: Flashcards.Show running on the Windows Phone emulator&lt;/p&gt;  &lt;p&gt;The Flashcards.Show application runs on Windows Phone as a Silverlight application and can display the same deck that the WPF application shared with the web Silverlight. The same content and the same games can be played on Windows, on the web running Silverlight, and on Windows Phone. &lt;/p&gt;  &lt;p&gt;If you want to download the application, feel free to use the &lt;a href="http://flashcardsshowclient.blob.core.windows.net/flashcards/WPFClient/FlashCards.Show.application"&gt;Flashcards.Show ClickOnce install&lt;/a&gt;. If you want access to the code, please visit &lt;a href="http://code.msdn.microsoft.com/FlashCards"&gt;Flashcards&lt;/a&gt; on MSDN Code Gallery. &lt;/p&gt;  &lt;p&gt;So there you have it – a single application that run on three different platforms backed by Windows Azure as the supporting cloud service. The nice thing about the entire Flashcards.Show implementation is our ability (by design) to share a lot of code and resources between WPF, Silverlight, and Windows Phone. &lt;/p&gt;  &lt;p&gt;&lt;img style="display:block;float:none;margin-left:auto;margin-right:auto;" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-53-70-metablogapi/3201.Drawing1_5F00_244C2AD1.jpg" alt="" /&gt;&lt;/p&gt;  &lt;p align="center"&gt;Figure 4: Flashcards.Show high level architecture &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;How does it work?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The Flashcards.Show application is built from two main components: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The suite of client applications – WPF for Windows, Silverlight for web, and Windows Phone &lt;/li&gt;    &lt;li&gt;The cloud piece, a series of web services running on Windows Azure backed by Azure storage. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;In this series of posts, we will NOT explain the cloud part, but will focus on the Silverlight and Windows Phone implementations.&lt;/p&gt;  &lt;p&gt;When you download the &lt;a href="http://code.msdn.microsoft.com/FlashcardsShow-84f2b3ba"&gt;Flashcard.Show version 2 source code&lt;/a&gt;, you will find a single Visual Studio solution file (FlashCardsSolution) that contains 10 different projects:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;FlashCards.UI.Phone&lt;/strong&gt; – Contains the Windows Phone application, including the different pages and resources &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;FlashCards.UI.SL&lt;/strong&gt; – Contains the Silverlight application, including the different pages and resources &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;FlashCards.UI.WPF&lt;/strong&gt; – Contains the main Windows application, including both modes, Admin and Game &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;FlashCards.ViewModel.Phone&lt;/strong&gt; – Contains the View-Model piece of the MVVM architecture that is used in the Windows Phone application &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;FlashCards.ViewModel.SL&lt;/strong&gt; – Contains the View-Model piece of the MVVM architecture that is used in the Silverlight application &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;FlashCards.ViewModel.WPF&lt;/strong&gt; – Contains the View-Model piece of the MVVM architecture that is used in the Windows application &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;FlashCardsServices&lt;/strong&gt; – Contains the Windows Azure project that references the services that are deployed with it &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;FlashCardsServices.Contracts&lt;/strong&gt; – Contains the definition of the services use by the various Flashcards.Show applications &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;FlashCardsServices.Entities&lt;/strong&gt; – Contains the model of the supporting web services &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;FlashWCFWebRole&lt;/strong&gt; – Contains the web services that the different Flashcards.Show applications use &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Looking at the above list, you might be asking yourself, what are the duplications between the different ViewModel projects and the UI projects? &lt;/p&gt;  &lt;p&gt;To start with, we have to compile for the target platform (Windows, Silverlight, and Windows Phone), you have no other option but to compile to the required target CLR. For a little bit of background, please watch Shawn Burke’s “&lt;a href="http://bit.ly/aUlqkU"&gt;3-Screen Coding: Sharing code between Windows Phone, Silverlight, and .NET&lt;/a&gt;”. This sample, doesnt use the library Shawn is referring to in his talk, but it would sure make our life easier. &lt;/p&gt;  &lt;p&gt;However, that doesn’t mean we just have to duplicate code. This is especially true in regards to the ViewModel (part of MVVM) piece of the application. Since all clients basically share the same model, they all have the same logic and display the same games and screen flow. Therefore, as you can see from the figure on the left, the WPF view-model (FlashSards.ViewModel.WPF) is the main view model we are using, and the phone’s view-model (FlashSards.ViewModel.Phone) and Silverlight view-model (FlashSards.ViewModel.SL) simply &lt;b&gt;link&lt;/b&gt; to the relevant view model files. As you can see from the image, little arrows indicate that the relevant files are linked (click on the image to the left to see a larger version of it). This shows that we are maintaining a single view-model for all clients.&lt;/p&gt;  &lt;p&gt;&lt;img style="display:block;float:none;margin-left:auto;margin-right:auto;" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-53-70-metablogapi/6746.image41_5F00_4D5A5301.png" width="207" height="547" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;The UI is a little bit trickier. The difference between Silverlight 3 and WPF 4 runtimes are such that in our case, it is easier to simply rewrite the Silverlight application (remember, we choose to target SL3 to make the porting to Windows Phone easier). The FlashCards.UI.SL is a Silverlight project that mimics a lot of the WPF functionality, but with Silverlight capabilities. &lt;/p&gt;  &lt;p&gt;You can still leverage all of your .NET and WPF skills as you write the Silverlight XAML and use data binding. We deliberately targeted Silverlight 3 and not Silverlight 4 because Windows Phone Silverlight runtime is version 3. The reason is simple; we wanted the easiest possible port from Silverlight to Windows Phone. And the outcome was just that, a super easy port from Silverlight to Windows Phone. It took about 3 days to make the Silverlight application run on Windows Phone. &lt;/p&gt;  &lt;p&gt;As you can see from the figure to the left, most of the Windows Phone UI project- FlashCards.UI.Phone files are links (including the folders that are collapsed in image #6.). The links point to the Silverlight web application implementation FlashCards.UI.SL.&lt;/p&gt;  &lt;p&gt;The files that could not be linked are those under Views. These files include XAML that is directly related to the way we display the specific pages on the phone. The phone’s form-factor is much smaller, and therefore we can fit fewer objects into it. With that in mind the implementation of the XAML was similar but not identical.&lt;/p&gt;  &lt;p&gt;&lt;img style="display:block;float:none;margin-left:auto;margin-right:auto;" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-53-70-metablogapi/4863.image52_5F00_5D19E805.png" width="214" height="558" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;Unlike regular C# code, XAML doesn’t support of &lt;b&gt;#ifdef&lt;/b&gt;, therefore we had to write new XAML for all the views in the game. But even then we could copy large parts of the already existing XAML. &lt;/p&gt;  &lt;p&gt;At this stage I am not going to jump into the details of the implementation, mainly because there are a lot of them. You are more than welcome to &lt;a href="http://code.msdn.microsoft.com/FlashcardsShow-84f2b3ba"&gt;download&lt;/a&gt; the source code, which includes documentation. You can also &lt;a href="http://channel9.msdn.com/posts/FlashcardsShow-Version-2-running-on-Windows-Phone-and-IE"&gt;watch&lt;/a&gt; a short video on C9.&lt;/p&gt; &lt;object type="application/x-silverlight-2" data="data:application/x-silverlight-2," width="512" height="288"&gt;&lt;param name="minRuntimeVersion" value="4.0.50401.0" /&gt;&lt;param name="source" value="http://channel9.msdn.com/scripts/Channel9.xap?v=1.3" /&gt;&lt;param name="initParams" value="mediaurl=http://media.ch9.ms/ch9/b72d/74f823fb-b458-47a6-b024-9e8c0143b72d/FlashcardsShow_ch9.wmv,thumbnail=http://media.ch9.ms/ch9/b72d/74f823fb-b458-47a6-b024-9e8c0143b72d/FlashcardsShow_512_ch9.jpg,deliverymethod=progressivedownload,autoplay=false" /&gt;&lt;/object&gt;  &lt;p&gt;I want to thank &lt;a href="http://blogs.microsoft.co.il/blogs/arik/"&gt;Arik Poznanski&lt;/a&gt; who helped drive the second phase of Flashcards.show.&lt;/p&gt;  &lt;p&gt;Follow Windows Phone announcements on Twitter at &lt;a href="http://twitter.com/wp7dev"&gt;WP7DEV&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Follow &lt;a href="http://twitter.com/yochayk"&gt;Yochay on Twitter&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Get &lt;a href="http://create.msdn.com/en-US/"&gt;started&lt;/a&gt; with &lt;a href="http://create.msdn.com/en-us/home/getting_started"&gt;free tools&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/wp7trainingcourse.aspx"&gt;free training&lt;/a&gt;, and &lt;a href="http://windowsteamblog.com/windows_phone/b/wpdev/archive/2010/08/17/windows-phone-7-jump-start-training.aspx"&gt;free Jump Start video course&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;(Post edited by Barbara Alban)&lt;/p&gt;  &lt;p&gt;[end of cross-post]&lt;/p&gt;  &lt;p&gt;That’s it for now,    &lt;br /&gt;Arik Poznanski&lt;/p&gt;&lt;div class="wlWriterHeaderFooter" style="margin:0px;padding:0px 0px 0px 0px;"&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/03/04/flashcards-show-version-2-for-the-desktop-browser-and-windows-phone.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/03/04/flashcards-show-version-2-for-the-desktop-browser-and-windows-phone.aspx&amp;amp;bgcolor=6600FF" /&gt;&lt;/a&gt; &lt;a href="http://dotnetshoutout.com/Submit?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/03/04/flashcards-show-version-2-for-the-desktop-browser-and-windows-phone.aspx"&gt;&lt;img alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http://blogs.microsoft.co.il/blogs/arik/archive/2011/03/04/flashcards-show-version-2-for-the-desktop-browser-and-windows-phone.aspx" style="border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=172641" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt; &lt;/div&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=801071" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Windows+Azure/default.aspx">Windows Azure</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/SDP/default.aspx">SDP</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/FlashCards.Show/default.aspx">FlashCards.Show</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/Azure/default.aspx">Azure</category><category domain="http://blogs.microsoft.co.il/blogs/arik/archive/tags/SDP+2011/default.aspx">SDP 2011</category></item></channel></rss>