<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Amit Chatterjee's Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/amit_chatterjee/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/amit_chatterjee/feed.xml</link>
    <description>Visual Studio, Development and Testing, Virtualization, and other topics</description>
    <lastBuildDate>Tue, 16 Apr 2019 04:37:10 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Submitting the Windows Phone application to the Marketplace</title>
      <link>https://docs.microsoft.com/archive/blogs/amit_chatterjee/submitting-the-windows-phone-application-to-the-marketplace</link>
      <pubDate>Sat, 30 Jul 2011 00:52:08 GMT</pubDate>
      <dc:creator><![CDATA[Amit_Chatterjee']]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amit_chatterjee/2011/07/30/submitting-the-windows-phone-application-to-the-marketplace/</guid>
      <description><![CDATA[The last several weeks have been quite busy at work. However, I finally found the time to publish my...]]></description>
      <content:encoded><![CDATA[<p>The last several weeks have been quite busy at work. However, I finally found the time to publish my application to the market place and it now now live there, with a few downloads reported too! In this post I will walk you through the steps involved in submissions, and share with you my experience.</p>  <h2></h2>  <h2></h2>  <h2></h2>  <h2></h2>  <h1></h1>  <h2></h2>  <h2></h2>  <h2></h2>  <h2></h2>  <h2></h2>    <h2></h2>  <h2></h2>  <h2></h2>  <h2></h2>  <h2>Registering at the App Hub</h2>  <p>Before you can submit an app to the market place, you first need to register for “App Hub” membership. You do this by going to <a href="http://create.msdn.com">http://create.msdn.com</a>. This essentially is a vibrant community of app and game developers for both Windows Phone and XBOX live games. The hub provides free tools, information, and the community you need to create and publish beautiful apps and games that reach every Windows Phone user and XBOX live members worldwide. Here’s how the home screen looks before you sign up</p>  <p>You first need to register for an annual subscription of $99 USD that gives you the following privileges for both the world of phone apps and XBOX.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6683.image_02078DB9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6683.image_5F00_02078DB9.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5516.image_thumb_2CFF7BBE.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5516.image_5F00_thumb_5F00_2CFF7BBE.png" width="554" height="196" /></a></p>  <p>The registration itself is a 5 step process as noted below and is quite simple. I show some of the screens below as well</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2772.image_5B9584A0.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2772.image_5F00_5B9584A0.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4431.image_thumb_0B702662.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4431.image_5F00_thumb_5F00_0B702662.png" width="204" height="239" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7658.clip_image002_44A68D57.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7658.clip_5F00_image002_5F00_44A68D57.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image002" border="0" alt="clip_image002" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1385.clip_image002_thumb_0F1DA565.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/1385.clip_5F00_image002_5F00_thumb_5F00_0F1DA565.jpg" width="354" height="279" /></a></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8306.clip_image00211_3A15936A.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/8306.clip_5F00_image00211_5F00_3A15936A.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image002[11]" border="0" alt="clip_image002[11]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5076.clip_image00211_thumb_6F5EA5CF.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5076.clip_5F00_image00211_5F00_thumb_5F00_6F5EA5CF.jpg" width="279" height="248" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1348.clip_image00213_140FBD47.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/1348.clip_5F00_image00213_5F00_140FBD47.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image002[13]" border="0" alt="clip_image002[13]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4064.clip_image00213_thumb_56FB65E7.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4064.clip_5F00_image00213_5F00_thumb_5F00_56FB65E7.jpg" width="279" height="252" /></a></p>  <p>Once signed up, the App Hub home screen now looks like the following. Notice the advertisement for the next version of Windows Phone, code named Mango! I can’t wait to upgrade my phone, and have been waiting to finish this tutorial and getting my application published!. My next app will be on Mango!</p>  <p>Also notice that the action on the App Hub are different now – for example, you get the option of “Submitting for Windows Phone”</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1325.image_4295A05C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/1325.image_5F00_4295A05C.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8357.image_thumb_2F349E23.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/8357.image_5F00_thumb_5F00_2F349E23.png" width="554" height="302" /></a></p>  <h2></h2>  <h2></h2>  <h2>The App Submission flow</h2>  <p>The following diagram captures the flow involved in the app submission process</p>  <p>&#160;</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4135.image_3E77DA65.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4135.image_5F00_3E77DA65.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5102.image_thumb_43D6253C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5102.image_5F00_thumb_5F00_43D6253C.png" width="554" height="573" /></a></p>  <p>We have of course so far been focusing on the first step of the process – creating the application in Visual Studio. I have also been developing using the Emulator. Before submitting the application it is of course also very important to test on an actual device. To do this however you will need to “Unlock” the phone. To do this, connect a phone device to your laptop using the USB (charging) cable, and the run the “Windows Phone Developer Registration” application from the Windows Start menu (this application gets installed on your system when you download the phone development tool kit). The application looks like the following – it takes in your Live ID and then “Unlocks” the phone device so that Visual Studio can deploy the phone application binary directly onto the phone device. </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0486.image_08FE5699.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0486.image_5F00_08FE5699.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1070.image_thumb_59BC4534.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/1070.image_5F00_thumb_5F00_59BC4534.png" width="404" height="367" /></a></p>  <p>In Visual Studio you can select the “Windows Phone 7 Device” as the target for the publishing as shown in the Visual Studio Menu bar below. Now when you build and publish, the application will be deployed on the device and you can do your pre-certification device testing there. The application of course worked well for me there.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2626.image_7DF103E9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2626.image_5F00_7DF103E9.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0804.image_thumb_5AE09279.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0804.image_5F00_thumb_5F00_5AE09279.png" width="404" height="62" /></a></p>    <h6></h6>  <h2></h2>  <h2></h2>  <h2></h2>  <h2>The Certification Process</h2>  <p>The certification process is of course the most important part of the submission. The goal is to ensure that before any application or game is taken into the market place, it is certified that the application is reliable, it makes efficient use of device resources, the do not adversely interfere with the device functionality, and that they are free of any malicious software. </p>  <p>The full certification and submission process is as outlined below.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3515.image_17B5144C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/3515.image_5F00_17B5144C.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0871.image_thumb_5FB32068.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0871.image_5F00_thumb_5F00_5FB32068.png" width="554" height="258" /></a></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4572.image_33D2A6AC.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4572.image_5F00_33D2A6AC.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0066.image_thumb_6D090DA1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0066.image_5F00_thumb_5F00_6D090DA1.png" width="554" height="130" /></a></p>  <h2>The flow through the certification process</h2>  <p>The following screen shots show the flow, as I proceeded with each step of the certification process. </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7384.image22_498C693C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7384.image22_5F00_498C693C.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4152.image22_thumb_6D25453C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4152.image22_5F00_thumb_5F00_6D25453C.png" width="554" height="348" /></a></p>  <p>The submission process starts with the “Upload” step where you select the name of the application, give it a version number, and point to the .XAP file in the bin\release directory where Visual Studio builds the application. Note that the entire application is contained in single binary manifest file of extension XAP. This is shown below.</p>  <p>On hitting next on this screen, the submission process found one error – that my application did not have the locale information marked correctly. At this point I had to add the following lines to the MainPage.xaml.cs to mark the locale as “English”, recompile the application to regenerate the XAP file, test it, and redo the application submission process.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5710.image_651D7D0D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5710.image_5F00_651D7D0D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2260.image_thumb_2AC2072C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2260.image_5F00_thumb_5F00_2AC2072C.png" width="404" height="77" /></a></p>  <p>The next step is to describe the application by providing information that will later show up in the application market place.<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0508.image26_0889FBA6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0508.image26_5F00_0889FBA6.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0167.image26_thumb_6E396CB4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0167.image26_5F00_thumb_5F00_6E396CB4.png" width="554" height="455" /></a></p>  <p>This information will help potential buyers decide whether they want to try or buy your application or not. Here you choose to describe the category that best describes what the application does, a detailed description, and also key words that will lead an application search to your application. This essentially is your “marketing” collateral for your app.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5023.image30_701695F0.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5023.image30_5F00_701695F0.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2210.image30_thumb_0BE77F4F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2210.image30_5F00_thumb_5F00_0BE77F4F.png" width="554" height="458" /></a></p>  <p>As part of this step, you are also needed to provide various icons and art work that are used in various places in the market place. Here note that the Large Mobile Tile app is really a mandatory image (as I would learn later) though it is not marked as such. This icon is used when you pin your application to the start page. Likewise the “Background Art” image is mandatory too – it will be used when your application shows up in the market place. You can also submit a set of screen shots for the application and these will further describe and “market” your app when listed in the market place. The most convenient place to capture the screenshots of course is when you test your application on the Emulator. You can use the Windows Snipping tool to capture the screen shots – however, be sure to avoid including any of the Emulator “chrome” in the screen shot – this too I found out later.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6560.image33_568E471C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6560.image33_5F00_568E471C.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5700.image33_thumb_70BE8A73.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5700.image33_5F00_thumb_5F00_70BE8A73.png" width="554" height="585" /></a></p>  <p>The next step is to select the price for your application, and also decide which market placed the app would be listed in. There are three different geographical regions as you see in the image below. Select carefully and check out the defaults – or your application may not show up in the right marketplaces. (Note, each phone user provides a Live ID when they configure their phone for us. The country the Live ID is associated with then becomes the default market place for the “Marketplace” application on the phone.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8512.image38_747C2F43.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/8512.image38_5F00_747C2F43.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7115.image38_thumb_63A45EC8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7115.image38_5F00_thumb_5F00_63A45EC8.png" width="554" height="517" /></a></p>  <p>The next step is to call out a set of testing instructions that will be carried out in the “backend” to make a final validation that the application works as designed. You can also select the publishing option – for example, you can select that the app be published as soon as the validation and certification is done, without any further interventions from you.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3718.image42_4027BA63.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/3718.image42_5F00_4027BA63.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6507.image42_thumb_6F29F63A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6507.image42_5F00_thumb_5F00_6F29F63A.png" width="554" height="403" /></a></p>  <p>The last step then is to click the “Submit” button and submit the application.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0245.image50_012613FB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0245.image50_5F00_012613FB.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1212.image50_thumb_095A3992.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/1212.image50_5F00_thumb_5F00_095A3992.png" width="554" height="524" /></a></p>  <p>You can track the state of the submission on the “My Dashboard” page at “App Hub”. For example, a couple of days later I noticed that my submission had run into issues. </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0724.image11_4CE1C4E7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0724.image11_5F00_4CE1C4E7.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2376.image11_thumb_7192DC5E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2376.image11_5F00_thumb_5F00_7192DC5E.png" width="404" height="540" /></a></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1854.image_55357471.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/1854.image_5F00_55357471.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1348.image_thumb_361F2B06.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/1348.image_5F00_thumb_5F00_361F2B06.png" width="554" height="444" /></a></p>  <p>As shown above, the certification had run into errors, and clicking on the “View Error” page leads you to a PDF file with details about the errors. The PDF files looked as follows</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7612.image_2074CC9C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7612.image_5F00_2074CC9C.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4048.image_thumb_20D0D9C4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4048.image_5F00_thumb_5F00_20D0D9C4.png" width="504" height="619" /></a></p>  <p>In my case all of the errors were related to the images and iconography. I was missing the large mobile tile app, and the background art image, and the application screenshot included the chrome of the Emulator. Also, it called out that one of the icons in my application was still the generic Windows Sunburst icon. I then proceeded to fix the errors and in the process created my own custom icon and images (using Microsoft Paint, and saving them as .PNG files of the different dimensions necessary, as called out in the submission process).</p>  <p>I also had to select the “United States” market place, as apparently in the last submission I had not selected it. </p>  <h2>The submission goes through </h2>  <p>This time the submission went through without errors – a couple of days later, it was nice to see on the “Dashboard” that the process had worked, the app was in the Marketplace and it showed there were a few downloads too. The dashboard provides you several reports and statistics of your application.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6675.image_68528D1E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6675.image_5F00_68528D1E.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5125.image_thumb_05783529.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5125.image_5F00_thumb_5F00_05783529.png" width="554" height="240" /></a></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2134.image_6267C3B8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2134.image_5F00_6267C3B8.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1070.image_thumb_2E532465.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/1070.image_5F00_thumb_5F00_2E532465.png" width="554" height="164" /></a></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7356.image_6C000C21.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7356.image_5F00_6C000C21.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6761.image_thumb_1044F0A4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6761.image_5F00_thumb_5F00_1044F0A4.png" width="554" height="247" /></a></p>  <h2>The App shows up in the Marketplace</h2>  <p>It was exciting to then checkout the Marketplace on my phone, search for “AmitC”, and have the app show up – and I could install it from there! To capture an image of the app in the market place, I launched the Zune application and searched for the app there – and there it was!</p>  <p>&#160;</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5661.image_146EC869.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5661.image_5F00_146EC869.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8054.image_thumb_72734017.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/8054.image_5F00_thumb_5F00_72734017.png" width="554" height="387" /></a></p>  <p>It felt great to build, blog, and publish about this simple Windows Phone application. I hope it has spurred some of the readers to write and publish your own application. I really liked the Visual Studio tooling experience and felt proud of my team which has developed this tooling!</p>  <p>On now to the Mango version of Windows Phone!</p>  <p>Cheers!</p>]]></content:encoded>
    </item>
    <item>
      <title>Unit Testing the Windows Phone 7 applications</title>
      <link>https://docs.microsoft.com/archive/blogs/amit_chatterjee/unit-testing-the-windows-phone-7-applications</link>
      <pubDate>Sun, 26 Jun 2011 02:21:00 GMT</pubDate>
      <dc:creator><![CDATA[Amit_Chatterjee']]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amit_chatterjee/2011/06/26/unit-testing-the-windows-phone-7-applications/</guid>
      <description><![CDATA[It&rsquo;s been a long while since my last blog post. With some additional responsibilities at work,...]]></description>
      <content:encoded><![CDATA[<p>It&rsquo;s been a long while since my last blog post. With some additional responsibilities at work, and a long trip to the US, I just did not find the time to update the blog with the latest developments. But I am happy to find time this weekend to bring the Chronometer Windows Phone 7 application to a logical closure. In this post I will also concentrate on the topic of unit testing windows phone applications.</p>
<h1>A functional change first &ndash; clearing the history</h1>
<p>However, before I get to unit testing, I would like to add a small feature to the application. This is about clearing the history of the events that get displayed in the Stopwatch page. I do this by adding a &ldquo;Clear History&rdquo; menu item to the AppBar and then add a handler for the menu item to do the job.</p>
<p>Here is the change in the XAML to add the menu item &ndash; notice the new ApplicationBar.MenuItem &ndash; the auto-completion intellisense feature when editing the XAML directly makes is very easy to add these UI elements.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7608.image_7CA1A5EC.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7608.image_5F00_7CA1A5EC.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0841.image_thumb_00CB7DB2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0841.image_5F00_thumb_5F00_00CB7DB2.png" width="554" height="153" /></a></p>
<p>The code for the click handler looks as follows:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5633.image_55B34412.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5633.image_5F00_55B34412.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8666.image_thumb_4557CC59.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/8666.image_5F00_thumb_5F00_4557CC59.png" width="554" height="336" /></a></p>
<p>The screens below capture how the menu item shows up, and (on clicking) clears up the event list history captured till that point.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8738.image_73EDD53B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/8738.image_5F00_73EDD53B.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7268.image_thumb_4179DBEF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7268.image_5F00_thumb_5F00_4179DBEF.png" width="279" height="516" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6663.image_7D75F7D7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6663.image_5F00_7D75F7D7.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5102.image_thumb_24A01B40.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5102.image_5F00_thumb_5F00_24A01B40.png" width="279" height="520" /></a></p>
<h1>Using Jeff Wilcox&rsquo;s unit testing framework &hellip;</h1>
<p>For unit testing Windows Phone (and other Silverlight) applications, I recommend using Jeff Wilcox&rsquo;s framework for unit testing. I highly recommend you watch Jeff&rsquo;s MIX10 session on this topic from <a href="http://www.jeff.wilcox.name/2010/03/mix10-testing-talk-online/">this</a> link. There are some limitations in the here &ndash; for example, you cannot unit test controls in the AppBar &ndash; but this is a pretty nice framework, and served my purpose of unit testing the application.</p>
<p>Jeff Wilcox&rsquo;s <a href="http://www.jeff.wilcox.name/2010/05/sl3-utf-bits/">blog</a> explains the framework and you can also use this link to download the bits needed from the bottom of his blog page. Another useful link that helped me in setting up the framework was this <a href="http://www.smartypantscoding.com/a-cheat-sheet-for-unit-testing-silverlight-apps-on-windows-phone-7">Cheat Sheet</a>.</p>
<p>As explained in the cheat sheet, I add a new Windows Phone project to the solution called WP7ChronomterUT, add a dll folder where I download the unit testing framework (and unblock the files), add references to the two dlls there, and create a new file call MainPageUT.cs where I will add the unit test. I also add a reference to the WP7Chronometer project. Below is a snapshot of how the new project looks &ndash; observe the references added.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2134.image_00B743E6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2134.image_5F00_00B743E6.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2626.image_thumb_6C8E018F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2626.image_5F00_thumb_5F00_6C8E018F.png" width="404" height="546" /></a></p>
<h1></h1>
<h1>Few more housekeeping things &hellip;</h1>
<p>I need to do a few more things before I get to the unit testing.</p>
<p>First, I move the TimeSpanPicker1 style definition from app.xaml (application scope) to MainPage.xaml (main page scope). Please note that this needs to be included in the&nbsp; &lt;phone:PhoneApplicationPage.Resources&gt; section and that entire section needs to be ahead of the Grid definition in MainPage.XAML. This scope change is being done to avoid some limitations of the unit testing framework.</p>
<p>Second, we need to add a reference to the Coding4Fun.Phone.Controls.Toolkit that we installed via NuGet, to the new unit test project. To do this, you simply click on &ldquo;Add Library Package Manager Reference&rdquo; option for adding a new reference, and simply &ldquo;install&rdquo; the reference for the above toolkit from the list presented (note, the toolkit will already be listed there since we have installed is as part of the solution).</p>
<p>Third, I need to allow the unit test project access to the internal UI elements in the main application. To allow this, I add the following line at the end of the AssemblyInfo.cs file under &lsquo;Properties&rsquo; node of the WP7Chronometer project (the main application)</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5353.image_2CB3F53D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5353.image_5F00_2CB3F53D.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2133.image_thumb_3D4BF02B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2133.image_5F00_thumb_5F00_3D4BF02B.png" width="404" height="34" /></a></p>
<h1>Launching the unit test framework &hellip;</h1>
<p>Since the project we are working on is specifically for unit testing, I would like &ldquo;application&rdquo; in this case to straightaway launch the unit testing framework and run the unit tests that I will write. To do this, I add the following code to the MainPage.xaml.cs file:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2133.image_61FD07A2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2133.image_5F00_61FD07A2.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7317.image_thumb_0641EC25.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7317.image_5F00_thumb_5F00_0641EC25.png" width="554" height="350" /></a></p>
<p>The above code instantiates the unit test framework, sets the root visual of the page to it (that is, what ever it will display), and also hooks up the back button to allow you to return back from drilling into test results.</p>
<p>Note, I also hide the system tray, otherwise it will hide the top of the test results screen.</p>
<p>I have also changed the page title and the application title in the MainPage.xaml file as follows:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4670.image_228F2E45.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4670.image_5F00_228F2E45.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7701.image_thumb_3901CCCC.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7701.image_5F00_thumb_5F00_3901CCCC.png" width="554" height="219" /></a></p>
<h1>Now we can write the actual unit tests &hellip;</h1>
<p>The framework, once launched as above, will look for a TestClass and TestMethods in the dll as is normal for unit testing. Below I have a set of simple unit tests written up, to verify some of the initial states of the Chronometer application</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7776.image_632154E7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7776.image_5F00_632154E7.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0116.image_thumb_1942CD37.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0116.image_5F00_thumb_5F00_1942CD37.png" width="554" height="297" /></a></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5126.image_1C943F12.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5126.image_5F00_1C943F12.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5873.image_thumb_44E37166.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5873.image_5F00_thumb_5F00_44E37166.png" width="554" height="235" /></a></p>
<p>The code above is pretty self-explanatory, and we are now ready to run the tests</p>
<h1></h1>
<h1>Running the unit tests &hellip;</h1>
<p>Simply set the WP7ChoronometerUT project as the start up project in the solution, build the solution, and launch it. The unit test framework loads, based on the above start up code, and presents the initial page of instructions as shown on the left below. It allows you the option of choosing the set of tests you want to run via tags (and gives instructions on how the tags work), and also counts down five seconds to choose the default option of running all tests. The screen on the right shows that all of the tests have been run, and all have passed (the green bar at the top). Also note the statistics at the bottom where it says 5 out 5 tests have passed (BTW, to allow this display to come through we disabled the SystemTray earlier).</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8004.image_014BC044.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/8004.image_5F00_014BC044.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5758.image_thumb_0063348D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5758.image_5F00_thumb_5F00_0063348D.png" width="279" height="516" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5417.image_20DA4E72.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5417.image_5F00_20DA4E72.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1682.image_thumb_798FDF6F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/1682.image_5F00_thumb_5F00_798FDF6F.png" width="274" height="514" /></a></p>
<p>You can drill down into the tests by clicking on the name MainPageUT (which is the file which has the tests), and you see the lists of tests in that set on the screen below left. You can drill down into each of the tests &ndash; for example, clicking on the &ldquo;CheckifTimerDisplayisZero&rdquo; shows the screen on the bottom left. It tells you more information about the test, including pass/fail status, and start/end/duration for that test. Also notice that the back button on the phone allows you to navigate back to the previous screen.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6064.image_67EFCED7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6064.image_5F00_67EFCED7.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8508.image_thumb_3D0744F8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/8508.image_5F00_thumb_5F00_3D0744F8.png" width="279" height="516" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3884.image_6B311AE5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/3884.image_5F00_6B311AE5.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8662.image_thumb_50E08BF4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/8662.image_5F00_thumb_5F00_50E08BF4.png" width="279" height="524" /></a></p>
<p>Just to give you a sense of how failing tests get reported, I can deliberately make one of the tests fails &ndash; for example, changing the Assert.AreEqual in the &lsquo;CheckifTimerDisplayisZero&rdquo; to Assert.AreNotEqual, and then on building and running the application you get the screens below. The framework calls out the overall status as fail, calls out the test that has failed, and allows you to drill down into why it has failed.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5187.image_561F4CD8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5187.image_5F00_561F4CD8.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5001.image_thumb_63E16D06.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5001.image_5F00_thumb_5F00_63E16D06.png" width="184" height="342" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2330.image_79E7D898.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2330.image_5F00_79E7D898.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1778.image_thumb_251C49D3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/1778.image_5F00_thumb_5F00_251C49D3.png" width="184" height="339" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2818.image_16FD5AD6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2818.image_5F00_16FD5AD6.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5127.image_thumb_347F1008.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5127.image_5F00_thumb_5F00_347F1008.png" width="184" height="339" /></a></p>
<p>This is all pretty neat! It felt great to experiment with the unit test framework for the phone!</p>
<p>I am almost done with this set of blogs &ndash; what remains is to create an account in the marketplace and actually deploy the app! I will come back shortly with that.</p>
<p>Cheers!</p>]]></content:encoded>
    </item>
    <item>
      <title>Visual Studio ALM vNext announced at TechEd 2011, Atlanta</title>
      <link>https://docs.microsoft.com/archive/blogs/amit_chatterjee/visual-studio-alm-vnext-announced-at-teched-2011-atlanta</link>
      <pubDate>Wed, 18 May 2011 04:52:58 GMT</pubDate>
      <dc:creator><![CDATA[Amit_Chatterjee']]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amit_chatterjee/2011/05/18/visual-studio-alm-vnext-announced-at-teched-2011-atlanta/</guid>
      <description><![CDATA[I am very excited – we just announced the vision for Application Life Cycle Management (ALM) in the...]]></description>
      <content:encoded><![CDATA[<p>I am very excited – we just announced the vision for <strong>Application Life Cycle Management (ALM)</strong> in the next version of Visual Studio, at TechEd 2011 North America, at Atlanta. In his key note address on May 16, Jason Zander shared the vision and the roadmap, and demonstrated some of the cool features you can expect in that release. </p>  <p>As you know, we have been working on great tooling for ALM since 2005, and the last big release was Visual Studio 2010, released in April 2010. The next release that we are working on will continue to build on the strength of the past releases. Our tooling encompasses the entire lifecycle for application development, as shown in the graphic below</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6175.image_2D74E200.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6175.image_5F00_2D74E200.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2055.image_thumb_05FAC33E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2055.image_5F00_thumb_5F00_05FAC33E.png" width="554" height="302" /></a></p>  <p>With each release, our focus has been on reducing the major sources of failure and waste in the lifecycle. Continuing on that journey, we have major investments in TFS, Test, and advanced tooling coming in the next version. Jason showcased some of these in his keynote at TechEd 2011 Atlanta – please read his <a href="http://blogs.msdn.com/b/jasonz/archive/2011/05/16/announcing-alm-roadmap-in-visual-studio-vnext-at-teched.aspx">blog post</a> on the vNext announcement. We have also put together a <a href="http://go.microsoft.com/?linkid=9772730">whitepaper</a> which provides a great overview of the motivation for vNext and captures some of the highlights and screenshots! </p>  <p>We are continuing to refine the experiences that Jason talked about, and I look forward to writing more about vNext soon!</p>  <p>Cheers!</p>]]></content:encoded>
    </item>
    <item>
      <title>Building Windows Phone 7 User Interface with Expression Blend</title>
      <link>https://docs.microsoft.com/archive/blogs/amit_chatterjee/building-windows-phone-7-user-interface-with-expression-blend</link>
      <pubDate>Wed, 11 May 2011 05:44:59 GMT</pubDate>
      <dc:creator><![CDATA[Amit_Chatterjee']]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amit_chatterjee/2011/05/11/building-windows-phone-7-user-interface-with-expression-blend/</guid>
      <description><![CDATA[Microsoft Expression Blend is a great tool for designing user interfaces. Expression Blend 4 for...]]></description>
      <content:encoded><![CDATA[<p>Microsoft Expression Blend is a great tool for designing user interfaces. Expression Blend 4 for Windows Phone provides a streamlined development workflow for Windows Phone 7 applications that was previously available for Silverlight and .NET applications only. You can refer to <a href="http://www.microsoft.com/expression/phone.aspx">this</a> link to figure out the version of the tool that best suits your purpose, including the option of the free version that is part of the Windows Phone 7 developer <a href="http://www.microsoft.com/expression/windowsphone/">toolkit</a>. </p>  <p>I have used Expressions Blend in couple of places in the Chronometer application that I have been building. You will find a series of blog posts on the topic, starting <a href="http://blogs.msdn.com/b/amit_chatterjee/archive/2011/03/26/building-a-windows-phone-7-application.aspx">here</a>. I find that Blend is a great way to get the styles for the user interface controls just right – rather than simply using the properties of the control, or hand coding the XAML. For example, in the <a href="http://blogs.msdn.com/b/amit_chatterjee/archive/2011/05/01/extending-the-chronometer-windows-phone-7-app-introducing-nuget-pivot-and-the-timespanpicker-control.aspx">last</a> post, I had introduced the TimeSpanPicker control for the countdown timer feature of the application. The heart of the control is a TextBox control for the input of the initial value of the timer. If you remember, the default definition, and the default look of the control looked as below:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3617.image_3A6818F4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/3617.image_5F00_3A6818F4.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6443.image_thumb_0EE3AC60.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6443.image_5F00_thumb_5F00_0EE3AC60.png" width="554" height="144" /></a></p>  <p>To make the display of the control consistent with the Stopwatch control, I need to change the background color to black, the font to Courier New, font size to 64, and font color to yellow. I could set most of these properties from the properties toolbox of the control in Visual Studio. However, the font size simply would not take effect. This is likely a bug in the phone toolkit, and I will look into it later. However, this led me to Expression Blend, and I found that you can create user interface styling in a really effective manner in there!</p>  <p>To use Expression Blend for designing the UI, simply right click on the MainPage.xaml file and click the “Open in Expression Blend …” menu as shown below.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3125.image_6F7155CC.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/3125.image_5F00_6F7155CC.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4212.image_thumb_0C2ACAE2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4212.image_5F00_thumb_5F00_0C2ACAE2.png" width="554" height="196" /></a></p>  <p>This launches&#160; Blend in the full design mode for the xaml, as shown below.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3175.image_1C761CCE.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/3175.image_5F00_1C761CCE.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4572.image_thumb_213884F0.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4572.image_5F00_thumb_5F00_213884F0.png" width="554" height="332" /></a></p>  <p>You can then navigate to the control you want, by expanding the Objects hierarchy in the bottom left of the tool. Below, I have navigated to the TimeSpanPicker control and have selected it. You can now see the properties of the control in the tool.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7652.image_01E5B850.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7652.image_5F00_01E5B850.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6278.image_thumb_3B487CAD.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6278.image_5F00_thumb_5F00_3B487CAD.png" width="554" height="332" /></a></p>  <p>Right click on the control, select “Edit Template” and then “Edit a Copy…”, as shown below</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4137.image16_07042D9A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4137.image16_5F00_07042D9A.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2084.image16_thumb_391B5817.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2084.image16_5F00_thumb_5F00_391B5817.png" width="254" height="255" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1817.image19_56AD3316.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/1817.image19_5F00_56AD3316.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7128.image19_thumb_1B79574B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7128.image19_5F00_thumb_5F00_1B79574B.png" width="304" height="255" /></a></p>  <p>Note that in the dialog box on the right you have two options – to define a new style in the context of the application, or just for the page in question. This determines whether the style definition will go into the App.xaml file or in the MainPage.xaml file. I would really like to define the style so that it is available for the entire application, so I will select the “Application” radio button as shown below.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3010.image_390B324A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/3010.image_5F00_390B324A.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2746.image_thumb_107C2A69.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2746.image_5F00_thumb_5F00_107C2A69.png" width="554" height="485" /></a></p>  <p>&#160;</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2376.image_5D7C7434.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2376.image_5F00_5D7C7434.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2705.image_thumb_0A150841.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2705.image_5F00_thumb_5F00_0A150841.png" width="554" height="327" /></a></p>  <p>Notice above that the Object hierarchy on the left now shows the components of the TimeSpanPicker control, and I have selected the DateTimeButton control to really select the specific control I want to change properties of. At this point, the properties palette on the right hand side makes it really easy to change the properties. In the screen below I show how I have changed the font to “Courier New” and the size to “48 points”. (I needed to resize the control size to accommodate the larger size).</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8270.image_4A1B71FB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/8270.image_5F00_4A1B71FB.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3005.image_thumb_562CC655.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/3005.image_5F00_thumb_5F00_562CC655.png" width="554" height="327" /></a></p>  <p>Next, I change the text foreground to yellow. For this I select the “Foreground” field in the “Brushes” section at the top right of Blend, and then click the little square button next to “foreground”, select “Custom Expressions” and type “yellow” as shown below. As you see, the text changes to yellow.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5468.image_78C0DF03.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5468.image_5F00_78C0DF03.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4810.image_thumb_0088D1A6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4810.image_5F00_thumb_5F00_0088D1A6.png" width="279" height="221" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1777.image_6BB6D925.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/1777.image_5F00_6BB6D925.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6404.image_thumb_5EACD347.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6404.image_5F00_thumb_5F00_5EACD347.png" width="279" height="117" /></a></p>  <p>To change the background, I click the button next to “Background” and this time I choose “System Resource” and then select “PhoneBackroundBrush” to ensure that the background of the control will match the background of the phone. At this point the control looks exactly the way I wanted it to be!   <br /></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6813.image_758BA4C3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6813.image_5F00_758BA4C3.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7002.image_thumb_4B4BD10E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7002.image_5F00_thumb_5F00_4B4BD10E.png" width="554" height="405" /></a></p>      <p>That’s all we needed to do in Expression Blend. We simply hit “File.Save All” in Expression Blend and exit out of Blend. You will now get a pop-up i informing you that the xaml file was edited outside of Visual Studio, as shown below. We will of course accept this change by clicking “Yes to All”.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8407.image_4D58AA0A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/8407.image_5F00_4D58AA0A.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0167.image_thumb_7F03A192.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0167.image_5F00_thumb_5F00_7F03A192.png" width="554" height="192" /></a></p>  <p>Notice that the designer in Visual Studio immediately displays the control in the new style.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8030.image_532327D6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/8030.image_5F00_532327D6.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8468.image_thumb_2A17C733.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/8468.image_5F00_thumb_5F00_2A17C733.png" width="554" height="329" /></a></p>  <p>Also, notice that the definition of the TimeSpanPicker control has also been automatically changed to reference the new static resource TimeSpanPickerStyle1 that we had created in Expression Blend!</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2526.image_1220BA40.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2526.image_5F00_1220BA40.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7713.image_thumb_652B5764.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7713.image_5F00_thumb_5F00_652B5764.png" width="554" height="125" /></a></p>  <p>If you remember, we had chosen to define the new style in the context of the full application. Hence the definition of the above new style is automatically incorporated in the App.xaml file – as shown below</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8306.image_5B82E92E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/8306.image_5F00_5B82E92E.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0572.image_thumb_439C0208.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0572.image_5F00_thumb_5F00_439C0208.png" width="554" height="290" /></a></p>  <p>That’s all. We now compile the application and a quick test shows that the timer functionality is working just fine, and the count down timer display shows correctly, and in the intended style, in both portrait and landscape modes</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4604.image_53E753F4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4604.image_5F00_53E753F4.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3443.image_thumb_4D905799.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/3443.image_5F00_thumb_5F00_4D905799.png" width="204" height="376" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6278.image_6A49CCAE.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6278.image_5F00_6A49CCAE.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5621.image_thumb_36057D9B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5621.image_5F00_thumb_5F00_36057D9B.png" width="314" height="169" /></a></p>  <p>&#160;</p>  <p>Expression Blend is very powerful designer tool, and it was fun dabbling with it a bit in building the Windows Phone 7 application!</p>  <p>Cheers!</p>]]></content:encoded>
    </item>
    <item>
      <title>Extending the Chronometer Windows Phone 7 app – introducing NuGet, Pivot, and the TimeSpanPicker control!</title>
      <link>https://docs.microsoft.com/archive/blogs/amit_chatterjee/extending-the-chronometer-windows-phone-7-app-introducing-nuget-pivot-and-the-timespanpicker-control</link>
      <pubDate>Sun, 01 May 2011 07:19:25 GMT</pubDate>
      <dc:creator><![CDATA[Amit_Chatterjee']]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amit_chatterjee/2011/05/01/extending-the-chronometer-windows-phone-7-app-introducing-nuget-pivot-and-the-timespanpicker-control/</guid>
      <description><![CDATA[I am back to coding this weekend, and would like to add a second feature to the Chronometer...]]></description>
      <content:encoded><![CDATA[<p>I am back to coding this weekend, and would like to add a second feature to the Chronometer application – a countdown timer. You will remember that I started building the application a few weekends back, and you will find the opening post <a href="http://blogs.msdn.com/b/amit_chatterjee/archive/2011/03/26/building-a-windows-phone-7-application.aspx">here</a>. I have since added a series of posts that has introduced different concepts and evolved the app – you can find those posts on my blog as well.</p>  <p>The concept of the Timer is of course very simple – you put in a text box with a value of hour : minute : second, and then put in some logic to change the values, and count it down to zero. However, I was looking for a control that would allow me to edit the countdown value with a nice experience – like you get when you set the alarm on the Windows phone 7!. I looked around, and found that there is control built by the community – called the TimeSpanPicker – which has the exact functionality I need. However, I would need to load the package, copy down the files, get any dependent packages (if any), add references to my project – and that is a lot of work!</p>  <p>This then provided me the opportunity to talk about the <strong>NuGet</strong> extension to Visual Studio. NuGet is a beautiful thing! You can read more about it <a href="http://nuget.codeplex.com/documentation?title=Getting%20Started">here</a>. It solves exactly the problem I have alluded to above, and I simply include an excerpt from the above link that explains the basic functionality.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5670.image_2B277718.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5670.image_5F00_2B277718.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2870.image_thumb_73258334.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2870.image_5F00_thumb_5F00_73258334.png" width="554" height="279" /></a></p>  <p>Let’s install the Library Package Manager (NuGet) extension. Click <strong>Tools</strong> and the <strong>Extension Manager</strong> – you can see below the packages I currently have installed. <strong>&#160;</strong></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7673.image_6900BC3C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7673.image_5F00_6900BC3C.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5123.image_thumb_541E9DEF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5123.image_5F00_thumb_5F00_541E9DEF.png" width="554" height="357" /></a></p>  <p>Now, click the <strong>Online Gallery </strong>tab. Visual Studio now searches the gallery and presents a list of packages, based on their ranking (the community rates the packages). The view on my system is displayed below, and you notice that the NuGet Package Manager is already listed at the top, with a 5-star rating from 70 voters!</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4861.image_1993784E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4861.image_5F00_1993784E.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7288.image_thumb_45BFD965.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7288.image_5F00_thumb_5F00_45BFD965.png" width="554" height="352" /></a></p>  <p>Simply click on the <strong>Download</strong> button to download and install the <strong>NuGet Package Manager</strong> package. It will download and install (once you accept the license agreement). After the installation you will be prompted to restart Visual Studio. If you now get back to the Extension Manager, you can see that the NuGet Package Manager is now installed.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0652.image_6ACCFE04.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0652.image_5F00_6ACCFE04.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1830.image_thumb_23678245.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/1830.image_5F00_thumb_5F00_23678245.png" width="554" height="352" /></a></p>  <p>Now we want to install the <strong>WP7 TimeSpanPicker </strong>control. For this, we go to the <strong>Tool, Library Package Manager, Add Library Package Reference</strong> option, and then select the <strong>Online</strong> tab to be able to pick from a list of packages out there. In the <strong>Search</strong> box now type “<strong>TimeSpan</strong>”. I got the following search results</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3302.image_6F233331.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/3302.image_5F00_6F233331.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6545.image_thumb_55AB0A2A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6545.image_5F00_thumb_5F00_55AB0A2A.png" width="554" height="313" /></a></p>  <p>I select the second one in the list (where the description says – “Just the timespan selector …”). </p>  <p>That’s all! The NuGet Package manager now downloads the package and adds references to the control into our project automatically, making it very simple to use the package.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1273.image_196F18B5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/1273.image_5F00_196F18B5.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6064.image_thumb_376D26A9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6064.image_5F00_thumb_5F00_376D26A9.png" width="404" height="169" /></a></p>  <p>I can now add the following line to the MainPage.xaml file to use the control in my layout – notice the last line in the xaml snippet below</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3733.image_3B96FE6E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/3733.image_5F00_3B96FE6E.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3326.image_thumb_474C45A0.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/3326.image_5F00_thumb_5F00_474C45A0.png" width="554" height="107" /></a></p>  <h2></h2>  <h2></h2>  <h2></h2>  <h2></h2>  <h2>Adding a Countdown timer to the Chronometer</h2>  <p>We will now add a Countdown timer to the Chronometer. The way I want this to work is that the Stopwatch will still be the default functionality. However, I would like to slide the Stopwatch page out and get a new “page” where I will have a countdown timer functionality – that is, a control where I can set a time duration (hh : mm : ss), allow the user to start the timer, and then count it down to 00 : 00 : 00 and sound an alert. </p>  <h2></h2>  <h2></h2>  <h2></h2>  <h2></h2>    <h2>Introducing a Pivot Control, and making the Stopwatch a PivotItem</h2>  <p>Once I add the Countdown timer, the Chronometer application will have two discrete features – the Stopwatch and the Countdown timer. On the Windows Phone 7, we have two different controls – the <strong>Pivot</strong> Control and the <strong>Panorama</strong> Control – that will allow me to arrange these two discrete features horizontally in a virtual space that is several times wider than the width of the phone. I can then move through the controls – and hence the two feature areas – by simply sweeping the application surface with the fingers. Each control allows you to have a collection of items called <strong>PivotItem</strong> and <strong>PanoramaItem</strong>, respectively, to define the discrete feature areas </p>  <p>I will use the <strong>Pivot</strong> control rather than the <strong>Panorama</strong> control for two specific reasons:</p>  <ul>   <li>The Pivot control sweeps each control completely to the next, where as the Panorama allows the items to overlap on the display as they sweep them in. For this application, allowing each of the features the full viewing surface will give a better user experience</li>    <li>More importantly, the Panorama control does not allow the Application Bar (at least, that is my understanding at this time), and I want that functionality. In fact, I will let each of the two features to have their own Application Bar</li> </ul>  <p>So far, the structure of the MainPage.xaml file looks like the following – with the fully expanded tree of controls shown on the right</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5481.image_4456E0ED.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5481.image_5F00_4456E0ED.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1185.image_thumb_749DB5A3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/1185.image_5F00_thumb_5F00_749DB5A3.png" width="404" height="272" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6560.image_382540F9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6560.image_5F00_382540F9.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8228.image_thumb_63F594E8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/8228.image_5F00_thumb_5F00_63F594E8.png" width="229" height="270" /></a></p>  <p> I will now introduce the Pivot Control and Pivot Items, and move the earlier definition of the Stopwatch Layout inside it. This is done, by adding the following xaml code for the Pivot control and the PivotItem</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6560.image_12F7D0C0.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6560.image_5F00_12F7D0C0.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5482.image_thumb_178DDB7A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5482.image_5F00_thumb_5F00_178DDB7A.png" width="554" height="114" /></a></p>  <p>Note, that the name of the Pivot control has been set as the Name of the Application, and the PivotItem has the name of the first feature – the Stopwatch. The rest of the original layout of the Stopwatch feature is now included within the PivotItem definition, and the definition is then closed off with the following tags. (The only other change I did was to move the Stopwatch display time TextBlock control a bit to the left, as it had gotten moved because of the above embedding)</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0537.image_663EF119.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0537.image_5F00_663EF119.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6404.image_thumb_4BFE87F5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6404.image_5F00_thumb_5F00_4BFE87F5.png" width="232" height="56" /></a></p>  <p>Also, as the application will have one of two ApplicationBar controls, I am moving the definition of ApplicationBar items into a resource block as shown below, and will programmatically select the one that is the right one for the context. This is done by the following xaml code snippet</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2287.image_69FC95E9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2287.image_5F00_69FC95E9.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0647.image_thumb_357BC3A1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0647.image_5F00_thumb_5F00_357BC3A1.png" width="554" height="116" /></a></p>  <p>With this, the definition of the layout now looks as follow – contrast that with the one shown above.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5824.image_71E4127E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5824.image_5F00_71E4127E.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3617.image_thumb_1B0BAABD.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/3617.image_5F00_thumb_5F00_1B0BAABD.png" width="324" height="252" /></a>A<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0640.image_4DEB1557.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0640.image_5F00_4DEB1557.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7506.image_thumb_4FD86460.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7506.image_5F00_thumb_5F00_4FD86460.png" width="189" height="253" /></a></p>  <p>Also, since we will now explicitly need to set the ApplicationBar. To do this, we first create a handler for the <strong>SelectionChanged </strong>event of the Pivot control. The code that sets the event handler and the code for the handler is shown below.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7002.image_01EF8EDE.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7002.image_5F00_01EF8EDE.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3201.image_thumb_00AAF5FF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/3201.image_5F00_thumb_5F00_00AAF5FF.png" width="554" height="32" /></a></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0181.image_7E8DF735.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0181.image_5F00_7E8DF735.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5850.image_thumb_677F75F9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5850.image_5F00_thumb_5F00_677F75F9.png" width="554" height="128" /></a></p>  <p>&#160;</p>  <p>A quick compilation of the code and running of the application shows that all of the functionality is intact – as shown below.</p>              <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2158.image_02881F3B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2158.image_5F00_02881F3B.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6862.image_thumb_3784889E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6862.image_5F00_thumb_5F00_3784889E.png" width="204" height="376" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2677.image_6DA600ED.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2677.image_5F00_6DA600ED.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2677.image_thumb_06FDDE5B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2677.image_5F00_thumb_5F00_06FDDE5B.png" width="304" height="164" /></a></p>    <h2>Adding a second PivotItem for the Countdown timer</h2>  <p>We will now introduce the Countdown timer as a second feature, by adding another PivotItem and including the <strong>TimeSpanPicker </strong>control that we have installed above. This is very simply done with the following xaml code for adding a second PivotItem in the Pivot control xaml that was shown above.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5710.image_7D557024.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5710.image_5F00_7D557024.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6708.image_thumb_7B38715B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6708.image_5F00_thumb_5F00_7B38715B.png" width="554" height="103" /></a></p>        <p>We then add a second ApplicationBar resource as shown below</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4336.image_464B6C1E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4336.image_5F00_464B6C1E.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5635.image_thumb_442E6D55.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5635.image_5F00_thumb_5F00_442E6D55.png" width="554" height="105" /></a></p>  <p>Here we have a two buttons – the play button to start the timer, and a cancel button to cancel the timer before it counts down. We have defined a handlers named “countdown_play_Click” and “countdown_cancel_Click”. We will add code for it soon, but for now, we will simply add the handler as an empty function (likewise for the other handler too). </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0844.image_283D385D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0844.image_5F00_283D385D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8461.image_thumb_12071D0B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/8461.image_5F00_thumb_5F00_12071D0B.png" width="554" height="84" /></a></p>  <p>Note that the cancel button is disabled by default. Also, we have copied down the cancel icon into the images folder and have set the build action to content.</p>  <h2></h2>  <h2></h2>  <h2></h2>          <h2>Changing the properties of the TimeSpanPicker control</h2>  <p>It is now time to beautify the TimeSpanPicker control and set some properties so that it is consistent with the properties we had set for the Stopwatch display timer TextBlock. If you click on the PivotItem in the xaml file that represents the TimeSpanPicker control, you will get it displayed in the designer mode as shown below</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0044.image_36B83482.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0044.image_5F00_36B83482.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0385.image_thumb_702B1EAC.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0385.image_5F00_thumb_5F00_702B1EAC.png" width="554" height="231" /></a></p>  <p>To beautify the control, I would like to set the background color to black, the text color to yellow (just to add a bit of color, like we set Stopwatch display to blue), set the font to be a fixed width font (courier new), and set the font size to 64. </p>  <p>As in the case of the Stopwatch Display Timer, I found the most effective way to do this is to create a style in Expression Blend and apply it to the control. Here is the style that I have created and saved in App.xaml file</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0385.image_50D8520C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0385.image_5F00_50D8520C.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6266.image_thumb_77E2EB81.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6266.image_5F00_thumb_5F00_77E2EB81.png" width="554" height="247" /></a></p>  <p>I simply apply the style – TimeSpanPickerStyle2 to the TimeSpanPicker control, as shown below, and you can also see the control now looks a lot nicer in the design view. I have also adjusted the location of the TimeSpanPikcer control to be around the same place as the Stopwatch Display Timer control.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2477.image_3F281BA7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2477.image_5F00_3F281BA7.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2806.image_thumb_2FF0F133.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2806.image_5F00_thumb_5F00_2FF0F133.png" width="554" height="265" /></a></p>  <h2></h2>  <h2></h2>  <h2></h2>          <h2>The beautiful editing capability of the TimeSpanPicker control</h2>  <p>The TimeSpanPicker control has a very nice built-in editing capability for changing the hour, minute, second portions of the display. The display is a TextBox, but when the user selects it, you can change the values using the infinite scrolling capability that it provides, keeping in mind the range of the values for hour, minute and second!</p>  <p>Notice below, how it looks like in real time. The picture on the left shows the display mode of the control. When you click on any of the three fields, it brings up the infinite scrolling control and you can get it scrolling by swiping it and then selecting the value you want. In this mode, the bottom of the screen shows the save and cancel buttons which can be used to save the new value. Thus, by clicking the save button, you get the new value for the control as shown in the right most image.,</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7612.image_571B149B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7612.image_5F00_571B149B.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5557.image_thumb_7CE11531.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5557.image_5F00_thumb_5F00_7CE11531.png" width="179" height="330" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6237.image_15FC6F6A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6237.image_5F00_15FC6F6A.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4174.image_thumb_1ACEFD59.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4174.image_5F00_thumb_5F00_1ACEFD59.png" width="179" height="325" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8228.image_710B8265.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/8228.image_5F00_710B8265.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4118.image_thumb_11829C4B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4118.image_5F00_thumb_5F00_11829C4B.png" width="179" height="330" /></a></p>  <p>However, note that to get the save and cancel images to show properly, you have to few steps explicitly (I presume this is an issue with the control – it should really have done all of these at the time of the package installation time).</p>  <p><i>Y</i>ou have to create a folder at the top level of the solution called &quot;Toolkit.Content&quot; and put the icons in there. You will need to copy the icons from the Coding4Fun.Phone.TestApplication project. They need be named &quot;ApplicationBar.Cancel.png&quot; and &quot;ApplicationBar.Check.png&quot;, and the build action must be &quot;Content&quot;!</p>      <h2>Finally, the logic for the Countdown timer</h2>  <p>To keep the logic for the Countdown timer simple, here is what I will do:</p>  <ul>   <li>Introduce a new DispatchTimer, let’s call it countdowntimer and a stopwatch called the countdownstopwatch. </li>    <li>When the “play” button on the Timer screen is hit, we will</li>    <ul>     <li>Convert the value in the timer to number of ticks, saving it, and setting that as the timespan interval for the counter</li>      <li>Set an event handler for the timer</li>      <li>Start the timer and the stopwatch</li>      <li>Disable the play button and enable the cancel button</li>   </ul>    <li>In the event handler of the timer</li>    <ul>     <li>We will get the elapsed timer time from the stopwatch, subtract it from the total number of ticks saved above to get the remaining time</li>      <li>If the remaining time is still positive, we will set the value of the TimespanPicker control to the remaining time</li>      <li>If the value has reached zero, we will stop the timer (we will soon sound a beep too)</li>      <li>We will also enable the play button and disable the cancel button</li>   </ul>    <li>When the cancel button is clicked, it simply resets the remaining time to zero and the event handlers take care of the rest</li> </ul>  <p>The code looks as follows:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1385.image_7CB0A3CA.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/1385.image_5F00_7CB0A3CA.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4527.image_thumb_1467DB31.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4527.image_5F00_thumb_5F00_1467DB31.png" width="554" height="75" /></a></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5123.image_1891B2F6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5123.image_5F00_1891B2F6.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2772.image_thumb_75ED747A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2772.image_5F00_thumb_5F00_75ED747A.png" width="554" height="160" /></a></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5826.image_52DD030A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5826.image_5F00_52DD030A.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2783.image_thumb_7F85BCE3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/2783.image_5F00_thumb_5F00_7F85BCE3.png" width="304" height="59" /></a></p>        <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3365.image_569AA7DA.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/3365.image_5F00_569AA7DA.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4442.image_thumb_0D28531F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4442.image_5F00_thumb_5F00_0D28531F.png" width="554" height="235" /></a></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6114.image_29E1C834.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6114.image_5F00_29E1C834.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7103.image_thumb_6F865252.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7103.image_5F00_thumb_5F00_6F865252.png" width="504" height="73" /></a></p>  <h2>Sounding a beep when the Countdown reaches zero</h2>  <p>Playing a sound when the countdown goes down to zero turned out to be harder than I thought. I will investigate if there is an easier way, however, for now I am accomplishing this using XNA.</p>  <p>First, I add couple of XNA class library references </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4861.image_066523CF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4861.image_5F00_066523CF.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0741.image_thumb_330DDDA8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0741.image_5F00_thumb_5F00_330DDDA8.png" width="304" height="45" /></a></p>  <p>Next, I add a audio file - Piano.wav - to the root of the Application. I also changed the “Piano.wav” as Content and “Always copy to Output Directory” in the properties of the .wav file. Finally, I add the code below when the countdown reaches zero.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0172.image_30F0DEDF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0172.image_5F00_30F0DEDF.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3005.image_thumb_1A4E9098.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/3005.image_5F00_thumb_5F00_1A4E9098.png" width="404" height="86" /></a></p>  <h2>How does the application looks?</h2>  <p>It is time now to build and show-off the features we have added. First notice the main screen of the application in the image shown on the left. You will notice that next to the “StopWatch” title, you will see a portion of the “Timer” feature shown in gray. This is a view of the Pivot control. It shows that there is another feature in the application! If you swipe the surface of the phone, it brings the second feature into view – as shown in the image on the right. Notice how the titles of the features are positioned – the Timer is now active, and the Stopwatch title shows partially and is grayed.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0268.image_5EAE81D7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0268.image_5F00_5EAE81D7.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4810.image_thumb_311D3C47.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4810.image_5F00_thumb_5F00_311D3C47.png" width="279" height="516" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6153.image_269C6827.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6153.image_5F00_269C6827.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6404.image_thumb_463B1C22.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6404.image_5F00_thumb_5F00_463B1C22.png" width="279" height="520" /></a></p>  <p>I can use the TimeSpanPicker editing capabilities discussed earlier and set a countdown value – as shown on the left below. When we save the value, you get the second image from the left – notice that the play button is enabled and the cancel is disabled. I then hit the play button and the third picture shows the countdown in progress and I also show it in a flipped view. Notice that the cancel button is now enabled, and when I click that the count goes to zero, as shown in the last picture below, and the piano sound plays as well!</p>  <p>&#160;</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4760.image_4847F51E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/4760.image_5F00_4847F51E.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7418.image_thumb_2F3BFF0C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/7418.image_5F00_thumb_5F00_2F3BFF0C.png" width="124" height="229" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5367.image_4CCDDA0B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5367.image_5F00_4CCDDA0B.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3125.image_thumb_36F3CBE1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/3125.image_5F00_thumb_5F00_36F3CBE1.png" width="124" height="229" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6355.image_1B6EC9DE.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6355.image_5F00_1B6EC9DE.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0412.image_thumb_143F6799.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/0412.image_5F00_thumb_5F00_143F6799.png" width="194" height="106" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6874.image_72075C12.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/6874.image_5F00_72075C12.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5314.image_thumb_127E75F8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-15-68-metablogapi/5314.image_5F00_thumb_5F00_127E75F8.png" width="124" height="226" /></a></p>  <p>That was truly a lot of fun! I have touched upon a ton of functionality, and I really enjoyed getting the application into shape and posting this!</p>  <p>Cheers!</p>]]></content:encoded>
    </item>
    <item>
      <title>Continuing with the Windows Phone applications–.NET Serialization</title>
      <link>https://docs.microsoft.com/archive/blogs/amit_chatterjee/continuing-with-the-windows-phone-applications-net-serialization</link>
      <pubDate>Sat, 23 Apr 2011 03:13:58 GMT</pubDate>
      <dc:creator><![CDATA[Amit_Chatterjee']]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amit_chatterjee/2011/04/23/continuing-with-the-windows-phone-applications-net-serialization/</guid>
      <description><![CDATA[The Chronometer application I have been building for Windows Phone 7 is coming along nicely! This...]]></description>
      <content:encoded><![CDATA[<p>The Chronometer application <a href="http://blogs.msdn.com/b/amit_chatterjee/archive/2011/03/26/building-a-windows-phone-7-application.aspx">I have been building</a> for Windows Phone 7 is coming along nicely! This has mostly been a weekend project, as I don’t find time to get to it during the working days. The Stopwatch functionality is almost complete. In the <a href="http://blogs.msdn.com/b/amit_chatterjee/archive/2011/04/16/building-a-windows-phone-7-application-data-binding-and-persistence.aspx">last post</a> I introduced the concept of data binding and persistence. I can now record a series of Stopwatch events, name the events, and when I exit (or tombstone) the application, I can persist them into a file. </p>  <p>In this post I will incrementally refine the application in a few different areas. The first one is to make the code for saving / loading the timings to and from the file lot simpler, by leveraging the power of .NET serialization. </p>  <p>If you remember, I had stored the timings from the Stopwatch in an in-memory data structure defined as follows:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0044.image_67ECC9E1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0044.image_5F00_67ECC9E1.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8867.image_thumb_1E0E4231.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/8867.image_5F00_thumb_5F00_1E0E4231.png" width="504" height="25" /></a></p>  <p>This is essentially an ObservableCollection object which represents the collection of timings. The object itself takes care of providing notifications when items get added, removed, or when the whole list is refreshed. The definition above takes a template for the class &lt;Timings&gt; which represents individual elements in the collections.&#160; The definition of the “Timings” class is shown below. Each element essentially is a tuple of two strings “EventName” for the name of the Stopwatch event, and “timingsinms” representing the time for the event.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8054.image_34ED13AD.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/8054.image_5F00_34ED13AD.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3107.image_thumb_24919BF4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/3107.image_5F00_thumb_5F00_24919BF4.png" width="554" height="504" /></a></p>  <p>The code to then save and load the in-memory collection object into a persisting file was explicitly written as:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6330.image_68192749.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6330.image_5F00_68192749.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7206.image_thumb_3E55AC56.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7206.image_5F00_thumb_5F00_3E55AC56.png" width="554" height="306" /></a></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3187.image_16CEBA1F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/3187.image_5F00_16CEBA1F.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2117.image_thumb_3F1DEC73.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/2117.image_5F00_thumb_5F00_3F1DEC73.png" width="554" height="444" /></a></p>  <h2></h2>  <h2></h2>  <h2></h2>  <h2></h2>        <h2>Leveraging .NET Serialization</h2>  <p>.NET provides the System.Xml.Serialization namespace that contains objects to help serialize objects into XML documents which can then be saved in files. Likewise, it provides classes for the deserialization too. You can read all of the details about .NET serialization <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization(v=VS.95).aspx">here</a>.</p>  <p>There are two options I can take - either to do an XMLSerialization or BinarySerialization. I am choosing XML since I could have a look at the file I need to and also tweak to choose the elements to be stored.</p>  <p>Since we are using an ObservableCollection which is part of System.Collection and types in System.Collection and System.Collection.Generic are by default Serializable. So it’s east just to serialize the entire collection with one line of code.</p>  <p>We first add System.Xml.Serialization as a reference, and include the name space in our project</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7801.image_3745D404.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7801.image_5F00_3745D404.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7206.image_thumb_7637549F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7206.image_5F00_thumb_5F00_7637549F.png" width="279" height="26" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5658.image_34506F51.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5658.image_5F00_34506F51.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8306.image_thumb_447C374A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/8306.image_5F00_thumb_5F00_447C374A.png" width="279" height="200" /></a></p>  <p>We then create an instance of the XmlSerializer class using the type of the object we want to serialize. </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7416.image_7A9DAF99.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7416.image_5F00_7A9DAF99.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7318.image_thumb_1FBAFA06.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7318.image_5F00_thumb_5F00_1FBAFA06.png" width="554" height="41" /></a></p>  <p>With this, the saving and loading of the in memory collection to the file become a lot easier.</p>  <p>To serialize to the file, the code now looks like the snippet shown below. We simply create a StreamWriter object for the file we have opened or created, and then serialize the instance of the XmlSerializer object (which has already been created of the write type), by calling the Serialize method, passing in the writer and the actual in memory collection as the parameters. </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6648.image_0B55347B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6648.image_5F00_0B55347B.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7737.image_thumb_1B80FC74.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7737.image_5F00_thumb_5F00_1B80FC74.png" width="554" height="146" /></a></p>  <p>Loading the collection back in to memory is equally simple.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6735.image_51A274C3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6735.image_5F00_51A274C3.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5353.image_thumb_2F6A693D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5353.image_5F00_thumb_5F00_2F6A693D.png" width="554" height="139" /></a></p>  <p>Note that the ObservableCollection does not fire the NotifyPropertyChanged when the whole collection is deserialized. So we overcome that by setting the Itemsource of the TextBox to the Collection once again.</p>  <h2></h2>          <h2>Handling the Application state during Deactivate and Closed events</h2>  <p>For the Main Application you will see there are four events that need to be handled and you can see the event handlers stubs already written for you in App.Xaml.cs. In our case we want to handle the case where when the user presses the back button or when the Windows button is pressed or when the user powers off the mobile when the app is in use, we want to store what we have in in memory list.</p>  <p>Currently we just have one screen and we will handle the Deactivated and Closed events when the main screen is being tombstoned.</p>  <p>Let’s first add the event for handling the de-activation. This is also an opportune time to show off a Visual Studio short cut mechanism to define and add these event handlers. Simply type:</p>  <p>&#160;</p>  <h3>“PhoneApplicationService.Current.Deactivated +=” </h3>  <p>Then hit the &lt;tab&gt; key twice. The code automatically expands to defining a default handler and setting the above event to the handler. See below</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8814.image_2C75048A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/8814.image_5F00_2C75048A.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6747.image_thumb_4353D606.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6747.image_5F00_thumb_5F00_4353D606.png" width="554" height="105" /></a></p>  <p>We will replace the default implementation with a call to “saveTimings” and likewise define and do the same for the Current.Closing event. The code for both is shown below.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8308.image_4E9CEA43.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/8308.image_5F00_4E9CEA43.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3122.image_thumb_0C49D200.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/3122.image_5F00_thumb_5F00_0C49D200.png" width="554" height="277" /></a></p>  <p>Since we are loading the timings when the application loads, and saving them when the application is deactivated, we no longer need to save the timings when the “Save” button is clicked – we will simply let the data structure build up in memory.</p>  <h2>Formatting the time </h2>  <p>Earlier we were calculating the time down to seconds and milliseconds by dividing the elapsedmilliseconds. We will now write it to the TImeSpan class and find out the Hours, minutes, seconds and milliseconds in one line of code.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2860.image_21E40A9D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/2860.image_5F00_21E40A9D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6663.image_thumb_26E6484C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6663.image_5F00_thumb_5F00_26E6484C.png" width="554" height="130" /></a></p>  <h2></h2>  <h2></h2>  <h2>&#160;</h2>  <h2>Fixing the font size and color of the timings</h2>  <p>Finally some aesthetic changes. I had noticed that the display style of the event name and that of the timings string were not quite the same. I have fixed that by appropriately defining the foreground brush for the TextBlock and its font size too – as shown in the XAML snippet below</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7824.image_5D07C09B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7824.image_5F00_5D07C09B.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7245.image_thumb_08D8148B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7245.image_5F00_thumb_5F00_08D8148B.png" width="554" height="89" /></a></p>  <h2>That completes the Stopwatch functionality.</h2>  <p>A quick test shows that the displays are looking much better, and the functionality is all intact</p>  <h2></h2>  <h2></h2>  <h2></h2>  <h2></h2>  <h2></h2>  <h2><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7762.image_37DA5062.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7762.image_5F00_37DA5062.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3542.image_thumb_3E110123.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/3542.image_5F00_thumb_5F00_3E110123.png" width="179" height="330" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6607.image_2866A2B9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6607.image_5F00_2866A2B9.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8357.image_thumb_24D55B51.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/8357.image_5F00_thumb_5F00_24D55B51.png" width="304" height="164" /></a></h2>    <p>Hitting the back button or hitting the “windows” button to tombstone button and getting back to the application also shows that the timings data is correctly being persisted and restored back</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0250.image_7DBA9C0E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0250.image_5F00_7DBA9C0E.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2313.image_thumb_574892F6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/2313.image_5F00_thumb_5F00_574892F6.png" width="279" height="516" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4162.image_4C5B8BE1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4162.image_5F00_4C5B8BE1.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6644.image_thumb_569C8A74.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6644.image_5F00_thumb_5F00_569C8A74.png" width="279" height="516" /></a></p>    <p>My goal for the next session and next post is to add another feature to the Stopwatch – that of a count down timer. That will need me to add another page to the application or perhaps a panoramic view – that will be fun!</p>  <p>Cheers!</p>]]></content:encoded>
    </item>
    <item>
      <title>Building a Windows Phone 7 Application–Data Binding and Persistence!</title>
      <link>https://docs.microsoft.com/archive/blogs/amit_chatterjee/building-a-windows-phone-7-applicationdata-binding-and-persistence</link>
      <pubDate>Sat, 16 Apr 2011 10:38:41 GMT</pubDate>
      <dc:creator><![CDATA[Amit_Chatterjee']]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amit_chatterjee/2011/04/16/building-a-windows-phone-7-applicationdata-binding-and-persistence/</guid>
      <description><![CDATA[The IPLT20 cricket championship is currently in progress – this means there is a lot of cricket on...]]></description>
      <content:encoded><![CDATA[<p>The <a href="http://www.iplt20.com/">IPLT20</a> cricket championship is currently in progress – this means there is a lot of cricket on Television. Usually a couple of games from 4pm to almost midnight! If you don’t have any other plans, these games are a great option to while away your evenings. I spend some time on the weekends watching these games. But I now have a happy solution to ensure watching the games doesn’t just become recreation but otherwise an unproductive use of time – I can continue to extend my Windows Phone Application and blog while I watch the games – woohoo! </p>  <p>It is time to add some new functionality and new concepts to the Chronometer application I have been building. I have posted a set of three blogs so far on it, with the first one being <a href="http://blogs.msdn.com/b/amit_chatterjee/archive/2011/03/26/building-a-windows-phone-7-application.aspx">here</a>.</p>  <h1></h1>  <h1></h1>  <h2>The new functionality that I will add</h2>  <p>In this post, I want to add the support of the “Save” functionality to the Stopwatch. If you remember, in the second post I had introduced the “Save” button in the Application Bar – however, I had not added any code for it. In this post I will add the following functionality.</p>  <ul>   <li>The “Save” button will be enabled only when the Stopwatch is in paused state (disabled with the watch is running)</li>    <li>When you hit “Save” it will do the following:</li>    </ul><ul>     <li>“Copy” the time on the Stopwatch to a new line below the Stopwatch</li>      <li>Any existing lines will be pushed down one row</li>      <li>Each new line will have a default name, and the Stopwatch time against it</li>      <li>The name of the line should be editable&#160; </li>      <li>The list of lines should be scrollable </li>      <li>The “Save” button should also reset the Stopwatch to “00:00:00:00”</li>   </ul>   <h2>&#160;</h2>  <h2>Persistence and data binding too</h2>  <p>It is important to mention here that, in the current release of the Windows Phone 7 only one application runs at a time. When you back out of your application, it gets suspended which is known as the “Tombstone” notion. While you get notifications of when the application gets tombstoned, but there is no guarantee that the application will be resumed from the same state when you go back to it. It may have gotten terminated (you would know that in the notification) and restarted. Hence it is important to take care of data persistence explicitly across tombstoning and restart. </p>  <p>I would like to save the list of timings displayed above from session to session. </p>  <p>For this, I will introduce the concept of persistence of the data in file, and I will also introduce the concept of data binding so that it makes it easy to associate and bind the data in the application screen to the file it is persisted in.</p>  <p>I am looking forward to learning a lot as I do this!</p>  <h2></h2>  <h2></h2>  <h2>Creating the visualization of the area where timings are saved</h2>  <p>I want the timings to be displayed as below:</p>  <h2 align="center">&lt;default timing name&gt;&#160;&#160;&#160;&#160; &lt;hh1:mm1:ss1:ttt1&gt;</h2>  <h2 align="center">&lt;default timing name&gt;&#160;&#160;&#160;&#160; &lt;hh2:mm2:ss1:ttt2&gt;</h2>  <h2 align="center">……..</h2>  <h2 align="center">&lt;default timing name&gt;&#160;&#160;&#160;&#160; &lt;hhn:mmn:ssn:tttn&gt;</h2>  <p align="left">While the name on each line starts with a default name (say “timing”), I want the name to be editable – so it needs to be TextBox. The actual value of the time however will be read-only (that value when save was hit) and hence it will be a TextBlock. </p>  <h2></h2>  <h2></h2>  <h2>First, a basic education in data binding to a control</h2>  <p>Let us first understand how data binding to a control works. There is already an excellent MSDN article <a href="http://create.msdn.com/en-US/education/quickstarts/Data_Binding_to_Controls">here</a>.&#160; Please study the article, especially the following concepts that we will use in our application. </p>  <ul>   <li>You have source and targets for binding, and a target is setup for binding using the “{Binding}” attribute value</li>    <li>There are two modes for binding – one way, and two way – via the BindingMode.OneWay (default) and BindingMode.TwoWay settings</li>    <li>The DataContext property of a framework or ui element allows it to participate in binding</li>    <li>The ObservableCollection&lt;T&gt; class that represents a dynamic data collection that provides notifications when items get added, removed, or when the entire list is refreshed</li>    <li>The INotifyPropertyChanged interface that notifies clients that a property value had changed</li>    <li>A DataTemplate that enables to customize how lists are displayed in a control, and ItemsControl.ItemTemplate that gets or sets the DataTemplate</li>    <li>The ItemsControl that can be used to represent a collection of items</li> </ul>  <p>At this point we are ready for create the new visualization that we need for our feature</p>  <h2>The main content display XAML</h2>  <p>I have created the design for the new content, and the XAML for that is shown below. You will notice that we have the “TimerDisplay” TextBlock at the top – this is the main display for the Stopwatch which we had introduced in the earlier posts – nothing has changed, I have however taken it out of the Grid which defines the new visualization that I will introduce now (and adjusted it’s margins to re-align it to where it was in the earlier posts.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7120.image_4F19729B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7120.image_5F00_4F19729B.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1460.image_thumb_7068F26A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1460.image_5F00_thumb_5F00_7068F26A.png" width="554" height="284" /></a></p>  <p>The new &lt;Grid /&gt; now introduces the new display. Notice the following carefully:</p>  <ul>   <li>For the make the entire Grid databound by marking <font color="#c0504d"><font color="#ff0000">DataContext</font>=<font color="#0000ff">”{</font>Binding</font><font color="#0000ff">}”</font><font color="#000000">. </font></li>    <li><font color="#000000">The Grid essentially contains a ListBox “MainListBox”, and note the ItemSource property and it is bound to “inmemList” which will be an in memory list</font></li>    <li>The ListBox has a StackPanel which essentially stacks up a TextBox for the name of the timings, and the TextBlock to save the time</li>    <li>The “Text” property of the TextBox and TextBlock are set to data bound to EventName and timingsms variables.</li>    <li><font color="#000000">Both of the above are set to TwoWay data binding</font></li> </ul>  <p><font color="#000000"></font></p>  <h2>The data structure that will hold the list of timings in memory</h2>  <p>As described earlier, the list of timings that the application will display is essentially a collection of tuples – with each tuple holding a string that represents the name of the event for which the Stopwatch was being used, and another string representing the timing value for that event. </p>  <p>We want to represent this as an ObservableCollection object with a class that holds the above tuple strings. This object will also fire the INotifyPropertyChanged event when any of the strings are changed. The data structure is simply the following:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5460.image_7F037882.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5460.image_5F00_7F037882.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7723.image_thumb_3D88C629.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7723.image_5F00_thumb_5F00_3D88C629.png" width="304" height="66" /></a></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1460.image_7416716D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1460.image_5F00_7416716D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5164.image_thumb_329BBF14.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5164.image_5F00_thumb_5F00_329BBF14.png" width="404" height="46" /></a></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5557.image_1063B38E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5557.image_5F00_1063B38E.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4578.image_thumb_20234892.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4578.image_5F00_thumb_5F00_20234892.png" width="404" height="472" /></a></p>      <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4062.image_38D26FD5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4062.image_5F00_38D26FD5.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2818.image_thumb_489204D9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/2818.image_5F00_thumb_5F00_489204D9.png" width="454" height="165" /></a></p>  <h2>Persisting the timings collection into a file</h2>  <p>Now lets get to the code that saves the above data structure – the timings collection – into a file, which essentially will be our backing store</p>  <p>The code for this is pretty simple and almost self explanatory. Here it is:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7608.image_1ECE89E6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7608.image_5F00_1ECE89E6.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5545.image_thumb_44580747.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5545.image_5F00_thumb_5F00_44580747.png" width="304" height="48" /></a></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3482.image_54179C4B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/3482.image_5F00_54179C4B.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0842.image_thumb_278E6C65.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0842.image_5F00_thumb_5F00_278E6C65.png" width="404" height="49" /></a></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3482.image_055660DF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/3482.image_5F00_055660DF.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4666.image_thumb_2A73AB4B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4666.image_5F00_thumb_5F00_2A73AB4B.png" width="404" height="74" /></a></p>  <p>Note, in the above code GetUserStoreForApplication essentially obtains a user-scoped isolated storage corresponding to the calling codes application identity. I will simply use a flat text file in the above storage for serializing and deserializing the timings collection data structure.</p>  <p>Here is the code which saves the data structure into a file, one line per timing tuple. It creates the file “acstopwatch.txt” if it is not already on the device, or opens it if it is there. The function is called with the collection. It then simply enumerates each element in the collection and writes out a line with the EventName and the timingsinms strings, separated by a comma.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6710.image_083B9FC5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6710.image_5F00_083B9FC5.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6116.image_thumb_37AA0E91.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6116.image_5F00_thumb_5F00_37AA0E91.png" width="554" height="306" /></a></p>    <p>The loading of the data structure from the file is likewise pretty simple. It opens the file, clears out the in-memory collection, reads one line at a time, and then splits the string at a comma to get the two texts stings that it creates a new Timing structure in the collection.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5127.image_0250D65F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5127.image_5F00_0250D65F.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2084.image_thumb_51DA51E8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/2084.image_5F00_thumb_5F00_51DA51E8.png" width="554" height="375" /></a></p>      <p>We will now do the initialization – where we will read the file, loading the in memory data structure, and set it as the data bound source for the MainListBox in our display that we created earlier in XAML. Note the last three lines in the code snipped below.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1004.image_078F9743.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1004.image_5F00_078F9743.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5127.image_thumb_2CACE1AF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5127.image_5F00_thumb_5F00_2CACE1AF.png" width="504" height="154" /></a></p>  <h2>The application visibly looks no different yet</h2>  <p>At this point we will build and run the application – and as expected, the application is visibly no different. The screen shot is shown below, and is really still where we had left off in the last blog. This is because while we aren’t really creating items in the MainListBox yet – that is the logic we now need to build into the play and save buttons. That comes up next.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2313.image_7BCA2A43.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/2313.image_5F00_7BCA2A43.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7774.image_thumb_37E5D01F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7774.image_5F00_thumb_5F00_37E5D01F.png" width="244" height="454" /></a></p>  <h1>Wiring in the new play/pause and save logic</h1>  <p>First we add the save handler to the save button in the application bar. At this point I also take the opportunity to rename the handler for the play button to what I had in the previous post to the following:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4544.image_1F92B604.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4544.image_5F00_1F92B604.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5621.image_thumb_16567AC3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5621.image_5F00_thumb_5F00_16567AC3.png" width="554" height="114" /></a></p>  <p>The play_click logic keeps the save button disabled while the stopwatch is in play mode, and enables it when in the pause or stop mode</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6114.image_4801724B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6114.image_5F00_4801724B.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5102.image_thumb_4BBF171B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5102.image_5F00_thumb_5F00_4BBF171B.png" width="504" height="335" /></a></p>  <p>The save logic is pretty simple – it adds a new item to the timings collection, gives it a default name based on the number of items in the collection, and resets the Stopwatch</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1586.image_08D01C23.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1586.image_5F00_08D01C23.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8741.image_thumb_4D9C4057.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/8741.image_5F00_thumb_5F00_4D9C4057.png" width="504" height="187" /></a></p>  <h2>Now we see the new UI and the Stopwatch logic is in place</h2>  <p>We are now ready to run the application. The screen below shows the Stopwatch running – see the save button displayed, then the pause mode where the save button is enabled, and on clicking the save notice the new line which shows up below the display.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7356.image_3F7D515A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7356.image_5F00_3F7D515A.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6758.image_thumb_7ADD8A8D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6758.image_5F00_thumb_5F00_7ADD8A8D.png" width="184" height="339" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1300.image_37B20C60.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1300.image_5F00_37B20C60.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1464.image_thumb_658F394B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1464.image_5F00_thumb_5F00_658F394B.png" width="184" height="342" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6242.image_34AC81E0.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6242.image_5F00_34AC81E0.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8080.image_thumb_2D7D1F9B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/8080.image_5F00_thumb_5F00_2D7D1F9B.png" width="184" height="339" /></a></p>  <p>Notice, since the event name is a text box, you can simply type in it to change the default name – as shown below</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4276.image_78901A5D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4276.image_5F00_78901A5D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0550.image_thumb_5FF05740.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0550.image_5F00_thumb_5F00_5FF05740.png" width="184" height="336" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4505.image_6105405F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4505.image_5F00_6105405F.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6646.image_thumb_7B3583B6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6646.image_5F00_thumb_5F00_7B3583B6.png" width="184" height="339" /></a></p>  <h2></h2>              <h2>Improving the style of the TextBox</h2>  <p>I don’t like the default look of the TextBox – the gray object – shown above. I would really like it to be like the TextBlock shown to the right. Perhaps there is a way to do this in the default designer –&#160; but this can also be done easily be designers who use Expression Blend.</p>  <p>My colleague at work is very handy with Blend – and he has a style which matches what I want and I would use that. For the purpose of this blog I will simply show the XAML generated by Blend for the style in question – and perhaps explore Blend at another time. </p>  <p>I am only showing a part of the XAML for the style, as it is a lot of XAML code (please let me know if you need the full style). I am putting this in the App.XAML file.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0451.image_0D31A177.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0451.image_5F00_0D31A177.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1121.image_thumb_4A72563E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1121.image_5F00_thumb_5F00_4A72563E.png" width="504" height="179" /></a></p>  <p>Next, I change the TextBox XAML definition to include the newly defined style</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7384.image_6DDED4D6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7384.image_5F00_6DDED4D6.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1033.image_thumb_650ECC8A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1033.image_5F00_thumb_5F00_650ECC8A.png" width="504" height="50" /></a></p>  <p>With that, when I run the application, the TextBox looks a lot nicer!</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4657.image_34984814.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4657.image_5F00_34984814.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2677.image_thumb_09AFBE35.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/2677.image_5F00_thumb_5F00_09AFBE35.png" width="244" height="447" /></a></p>    <h2>Some final screen shots</h2>  <p>We are done. Here are some final screen shots. The screen shows the state after a set of timings have been added, with some event names changed. The one on right shows that scrolling works just fine!</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0842.image_5860D3D4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0842.image_5F00_5860D3D4.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0820.image_thumb_2F6598FE.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0820.image_5F00_thumb_5F00_2F6598FE.png" width="204" height="373" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6765.image_5D8F6EEB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6765.image_5F00_5D8F6EEB.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0005.image_thumb_23900632.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0005.image_5F00_thumb_5F00_23900632.png" width="204" height="373" /></a></p>  <p>Next we hit the back button to tombstone the application, and when we launch it again, we see that it has reloaded all of the saved timings showing that persistence is working just fine too</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6763.image_4768B7BF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6763.image_5F00_4768B7BF.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1663.image_thumb_63A5D412.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1663.image_5F00_thumb_5F00_63A5D412.png" width="204" height="376" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5367.image_6B6DC6B4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5367.image_5F00_6B6DC6B4.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4300.image_thumb_610C7C87.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4300.image_5F00_thumb_5F00_610C7C87.png" width="204" height="376" /></a></p>        <p>Finally I test to see that portrait mode works well and it does!</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1134.image_5DAAE4DF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1134.image_5F00_5DAAE4DF.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2211.image_thumb_190B1E13.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/2211.image_5F00_thumb_5F00_190B1E13.png" width="404" height="221" /></a></p>  <p>That completes a few hours of coding this afternoon, and the cricket match is still on! I hope this blog is useful to someone out there who wants to add data binding and persistence to their application.</p>  <p>Cheers!</p>]]></content:encoded>
    </item>
    <item>
      <title>Windows Phone 7 app:  Adding “portrait”/“landscape” modes to Chronometer</title>
      <link>https://docs.microsoft.com/archive/blogs/amit_chatterjee/windows-phone-7-app-adding-portraitlandscape-modes-to-chronometer</link>
      <pubDate>Thu, 07 Apr 2011 09:22:15 GMT</pubDate>
      <dc:creator><![CDATA[Amit_Chatterjee']]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amit_chatterjee/2011/04/07/windows-phone-7-app-adding-portraitlandscape-modes-to-chronometer/</guid>
      <description><![CDATA[This one is a short update to the Windows 7 Phone application that I have been building and blogging...]]></description>
      <content:encoded><![CDATA[<p>This one is a short update to the Windows 7 Phone application that I have been building and blogging about – you can find the starting of the series <a href="http://blogs.msdn.com/b/amit_chatterjee/archive/2011/03/26/building-a-windows-phone-7-application.aspx">here</a>.</p>  <p>The application that we have built, so far, does not respond to flipping the phone on to it’s side. For example, below are two views of the phone held upright and on its side respectively</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7536.image_064E7EC3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7536.image_5F00_064E7EC3.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2450.image_thumb_27CA5BFA.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/2450.image_5F00_thumb_5F00_27CA5BFA.png" width="154" height="283" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8540.image_5256170A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/8540.image_5F00_5256170A.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8168.image_thumb_3E88E1DC.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/8168.image_5F00_thumb_5F00_3E88E1DC.png" width="304" height="165" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1830.image_7221286D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1830.image_5F00_7221286D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4810.image_thumb_04B5D68B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4810.image_5F00_thumb_5F00_04B5D68B.png" width="304" height="164" /></a></p>  <p>While this behavior may be fine for some applications, for our application, the display is hard to read when the phone is turned on its side, and I would really like the display to always be “upright” irrespective of whether the phone is held upright or flipped on it side.</p>  <p>This is easy to do!</p>  <p>You can find the default settings for the “orientation” for the application in the default XAML file for the application. I am including below this part of the XAML for the PhoneApplication page</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1261.image_01543EE3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1261.image_5F00_01543EE3.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4834.image_thumb_4C6739A5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4834.image_5F00_thumb_5F00_4C6739A5.png" width="554" height="206" /></a></p>  <p>Notice the last line above. It essentially says that the “Orientation” to start with will be in “Portrait” mode, and the “Supported Orientation” is also “Portrait” only. It is this setting which is making the application behave as shown above.</p>  <p>You can also notice this setting in the properties window for the PhoneApplicationPage object – see this in the image on the left below – notice the values of the “Orientation” and “SupportedOrientations” properties. To support both portrait and landscape orientations, all you need to do is change the value of the “SupportedOrientations” property to “PortraitOrLandscape” – see the image on the right below.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1134.image_2DDCAD22.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1134.image_5F00_2DDCAD22.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4762.image_thumb_6391F27C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4762.image_5F00_thumb_5F00_6391F27C.png" width="229" height="359" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5857.image_5F57F4EA.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5857.image_5F00_5F57F4EA.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2727.image_thumb_631599BA.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/2727.image_5F00_thumb_5F00_631599BA.png" width="294" height="357" /></a></p>  <p>As you change the above property, note that the XAML file automatically changed to reflect the change.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2161.image_37351FFE.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/2161.image_5F00_37351FFE.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7382.image_thumb_0C2D0C2C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7382.image_5F00_thumb_5F00_0C2D0C2C.png" width="554" height="206" /></a></p>  <p>That’s all! </p>  <p>We can now build the application, run it, and we can now see the following results when the phone is flipped on its side.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0572.image_26B95CAB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0572.image_5F00_26B95CAB.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4682.image_thumb_067E0454.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4682.image_5F00_thumb_5F00_067E0454.png" width="279" height="152" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3051.image_2186AD95.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/3051.image_5F00_2186AD95.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2061.image_thumb_46D05569.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/2061.image_5F00_thumb_5F00_46D05569.png" width="279" height="152" /></a></p>  <p>Notice, how the button icons in the application bar also change to match the corresponding orientation.</p>  <p>I should also call out that, you can just as well change these properties in the code. For example, you can achieve the same result by leaving the default properties (and hence the XAML) unchanged, but add the following line in the code behind file, during application initialization.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2084.image_319229F4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/2084.image_5F00_319229F4.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8875.image_thumb_15A0F4FC.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/8875.image_5F00_thumb_5F00_15A0F4FC.png" width="554" height="93" /></a></p>  <p>This of course gives you full flexibility in controlling this property however you want to!</p>  <p>That’s all for this night! I have a few other things to add to this application, related to the “Save” button I have introduced but haven’t coded to. This will allow me to play with a few more controls and also experiment with how data/state can be persisted across sessions of the application. I hope to get to those soon.</p>  <p>Cheers!</p>]]></content:encoded>
    </item>
    <item>
      <title>WP7 Chronometer – adding the ‘Application Bar’</title>
      <link>https://docs.microsoft.com/archive/blogs/amit_chatterjee/wp7-chronometer-adding-the-application-bar</link>
      <pubDate>Sat, 02 Apr 2011 08:22:42 GMT</pubDate>
      <dc:creator><![CDATA[Amit_Chatterjee']]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amit_chatterjee/2011/04/02/wp7-chronometer-adding-the-application-bar/</guid>
      <description><![CDATA[I have been waiting to get back to the Windows Phone 7 Chronometer app that I have started to build...]]></description>
      <content:encoded><![CDATA[<p>I have been waiting to get back to the Windows Phone 7 Chronometer app that I have started to build and blogged about last week. Today’s World Cup Cricket final provides the perfect setting to sit in front of the television to watch the game and get some coding done as well! </p>  <p>My goal today is to add the Application Bar functionality to the application, to use a different timer construct, and also to clean up the code a bit.</p>  <h2><font size="1"></font></h2>  <h2>Getting the ‘official’ icons </h2>  <p>Let me start first by using some professional icons for the application instead of the self-made ones in version 1.</p>  <p>You will find most of the important icons used on the Windows 7 phone already on the system. These come with the Windows Phone 7 developer toolkit, and you will them in the following locations:</p>  <ul>   <li>On 32 bit computers – C:\Program Files\Microsoft SDKs\Windows Phone\v7.0\Icons</li>    <li>On 64 bit computers – C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.0\Icons</li> </ul>  <p>You have both “dark” and “light” versions, I will be using the “dark” versions, as I have the default dark background for my Stop Watch page. I have copied over the following icons and add them to the project for the “save”, “pause”, and “play” functionality in the application, saving them in the “Images” folder</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5074.image_2893DB45.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5074.image_5F00_2893DB45.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0601.image_thumb_690677F4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0601.image_5F00_thumb_5F00_690677F4.png" width="244" height="78" /></a></p>  <p>Also, click on each of the icons, and in the properties window, change the “BuildAction” to “Content” from “Resource”</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4401.image_54A0B269.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4401.image_5F00_54A0B269.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8535.image_thumb_40A71FD3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/8535.image_5F00_thumb_5F00_40A71FD3.png" width="244" height="85" /></a></p>  <h2>Using a DispatchTimer</h2>  <p>In the last post I had used a Timer object. With this object, the callback happens on a different thread. Hence, to access the UI elements of the application, I had to use the Dispatcher.BeginInvoke mechanism on the object to access it. In this post, I will use the DispatchTimer object instead. For this class, the event callback happens on the UI thread itself, and I can access the UI elements directly. </p>  <p>To add the DispatchTimer, I add the following lines</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4426.image_4947785F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4426.image_5F00_4947785F.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7446.image_thumb_1CBE4879.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7446.image_5F00_thumb_5F00_1CBE4879.png" width="244" height="32" /></a></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5383.image_5AD7632A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5383.image_5F00_5AD7632A.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4426.image_thumb_6B6F5E18.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4426.image_5F00_thumb_5F00_6B6F5E18.png" width="304" height="35" /></a></p>        <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1108.image_375ABEC5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1108.image_5F00_375ABEC5.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7462.image_thumb_478686BE.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7462.image_5F00_thumb_5F00_478686BE.png" width="404" height="57" /></a></p>  <p>At this point, it is opportune to point out an useful short cut in Visual Studio. To add the event handler for the DispatchTimer object all you do is simply type</p>  <blockquote>   <p>timer.Tick += &lt;tab&gt; &lt;tab&gt; </p> </blockquote>  <p>Visual Studio automatically completes the rest of the last instruction shown in the snippet above, and also add the event handler code, below, automatically! I like this short cut!</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5327.image_44FD5500.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5327.image_5F00_44FD5500.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8176.image_thumb_0382A2A7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/8176.image_5F00_thumb_5F00_0382A2A7.png" width="404" height="87" /></a></p>  <h2>Changing the display font to a fixed-width type</h2>  <p>At this time, I will also make a few clean up changes. I clean up some of the static variables I had introduced earlier. I will also change the font type of the TimerDisplay TextBlock&#160; to “Courier New”. This is a “fixed width” font, and it will prevent the perceptible wobbling of the numbers in the timer display for the earlier version – that is, the total width of the displayed text will stay constant with this font, irrespective of the digits displayed. This requires me to change the width of the display block a bit, and I also take the opportunity to change the font color to a shade of blue to add a bit of color!</p>  <p>With this, the main part of the UI, and the properties of the TextBlock are the following</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7080.image_5A2B5AA8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7080.image_5F00_5A2B5AA8.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8407.image_thumb_4FAA8688.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/8407.image_5F00_thumb_5F00_4FAA8688.png" width="344" height="275" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8585.image_0C12D566.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/8585.image_5F00_0C12D566.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5367.image_thumb_29A4B065.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5367.image_5F00_thumb_5F00_29A4B065.png" width="304" height="272" /></a></p>  <h2>Introducing the Application Bar</h2>  <p>In this version I will also introduce the “Application Bar”. It is the bar that sits at the bottom of the screen. The bar supports four icons, and have additional menu items at the bottom. The bar displays just the icons and a “…” symbol on the right (bottom left of the screen) to expand the display bar and display the additional menu items. </p>  <p>The Visual Studio development environment makes it easy to make to bring the application bar into play! Double click on the MainPage.xaml file and check out the bottom of the xaml code – you will see the following xaml code in a comment block</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3617.image_5B4FA7ED.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/3617.image_5F00_5B4FA7ED.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0167.image_thumb_31F85FEF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0167.image_5F00_thumb_5F00_31F85FEF.png" width="604" height="176" /></a></p>  <p>Uncomment the comment block, and you see the Application Bar show up in the XAML designer view, as shown below</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0160.image_075C7F12.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0160.image_5F00_075C7F12.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6443.image_thumb_23A9C132.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6443.image_5F00_thumb_5F00_23A9C132.png" width="212" height="244" /></a></p>  <p>I have also cleaned up some of the old timer code and removed the old button that I had in version 1. At this time, you can build the application and run it. You can now see the Application Bar on the screen. The left image below shows the default display, and you can click the “…” icon at the bottom right of the screen and you can see the application bar expand, now showing the names of the two icons used, and also the additional menu items that are included in the XAML code above.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1581.image_679D7F7C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1581.image_5F00_679D7F7C.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2654.image_thumb_001CF700.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/2654.image_5F00_thumb_5F00_001CF700.png" width="204" height="379" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3666.image_760855D4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/3666.image_5F00_760855D4.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7875.image_thumb_153AD6DB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7875.image_5F00_thumb_5F00_153AD6DB.png" width="204" height="382" /></a></p>                  <p>I want to use the first of the icons in the application bar for the “start / pause” toggle for the Stop Watch, and the second one for a “save” functionality that I will introduce a bit later. </p>  <p>To do this, I update the XAML code in the Application Bar segment to change the icons for the first two icons to the play and save icons, comment out the extra menu items which I will not be using in this version, and also add the handler code for the two icon buttons. The XAML code for the Application Bar now looks as follows:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2273.image_78DD6EED.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/2273.image_5F00_78DD6EED.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0044.image_thumb_0EE3DA80.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0044.image_5F00_thumb_5F00_0EE3DA80.png" width="604" height="116" /></a></p>  <p>If you use the IntelliSense feature in Visual Studio to add the “Click” property, it will also add the handler code in the backing code file. I have changed the name to the one shown above/below</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4251.image_526B65D5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4251.image_5F00_526B65D5.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4667.image_thumb_37BEC9BC.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4667.image_5F00_thumb_5F00_37BEC9BC.png" width="504" height="104" /></a></p>  <p>Building the solution and running it, we can now see the Application Bar displayed with the two icons we have selected.</p>  <p>&#160;</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8306.image_033DF774.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/8306.image_5F00_033DF774.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0385.image_thumb_2D2DCFCF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0385.image_5F00_thumb_5F00_2D2DCFCF.png" width="244" height="458" /></a></p>  <p>When you click on the buttons, nothing happens yet, as I have not hooked up the code in the above handler to do the main stop watch logic. However, you will notice that the system automatically provides all of the functionality to “invert” the color of the icon when it is hit, and the subtle up-down motion showing the buttons are clicked.</p>  <h1></h1>        <h1>Putting back the logic for updating the display</h1>  <p>We can now put back the code we had in version 1 to update the display, taking care to put the logic in the appropriate event handlers, and accessing the new icons to update the application bar icons.</p>  <p>First I show below the code for clicking the first button in the Application Bar. It simply starts the DispatchTimer and Stopwatch, and simply toggles the icon images for the button from play to pause and vice-versa, and updates the icon text accordingly.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0486.image_509A4E67.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0486.image_5F00_509A4E67.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8233.image_thumb_7F9C8A3E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/8233.image_5F00_thumb_5F00_7F9C8A3E.png" width="504" height="292" /></a></p>  <p>Next, I show the code in the DispatchTimer callback. It simply updates the stopwatch components, and simply updates the Application’s TextBlock display directly from the thread (without having to use Dispatcher.BeginInvoke, as explained earlier in this post).</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1067.image_1BE9CC5F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1067.image_5F00_1BE9CC5F.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3652.image_thumb_207FD719.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/3652.image_5F00_thumb_5F00_207FD719.png" width="504" height="121" /></a></p>  <p>With this, we have are now back at the functional state we had in Version 1, but with the buttons in the Application Bar. Below are snapshots of the starting, running, and paused states of the application.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6607.image_24A9AEDE.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6607.image_5F00_24A9AEDE.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5611.image_thumb_047E7C54.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5611.image_5F00_thumb_5F00_047E7C54.png" width="169" height="313" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1832.image_0CB2A1EB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1832.image_5F00_0CB2A1EB.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4643.image_thumb_259E4C63.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4643.image_5F00_thumb_5F00_259E4C63.png" width="169" height="316" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3581.image_028DDAF3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/3581.image_5F00_028DDAF3.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5732.image_thumb_77C05DD0.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5732.image_5F00_thumb_5F00_77C05DD0.png" width="169" height="313" /></a></p>  <h2></h2>  <h2></h2>            <h2>Finishing up version 2 for now …</h2>  <p>The cricket match is at a very interesting stage now – it is quite tense, the last quarter of the match remains and India seems to be in a bit of discomfort and Sri Lanka has the upper hand. I better get back to paying complete attention and supporting Team India! I will keep evolving the application with further posts …</p>  <p>Cheers!</p>]]></content:encoded>
    </item>
    <item>
      <title>Building a Windows Phone 7 Application</title>
      <link>https://docs.microsoft.com/archive/blogs/amit_chatterjee/building-a-windows-phone-7-application</link>
      <pubDate>Sat, 26 Mar 2011 10:37:13 GMT</pubDate>
      <dc:creator><![CDATA[Amit_Chatterjee']]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amit_chatterjee/2011/03/26/building-a-windows-phone-7-application/</guid>
      <description><![CDATA[It’s a lazy Saturday afternoon, and was the perfect time for me to do something that I have been...]]></description>
      <content:encoded><![CDATA[<p>   <br /><font size="2">It’s a lazy Saturday afternoon, and was the perfect time for me to do something that I have been meaning to get to for a while now. That is, to develop a Windows Phone 7 application. No, I don’t have a brilliant application idea in mind (I will get to that another day), but this was more to just get my hands wet in developing a simple application. As I was developing it, the thought occurred, that it might not be a bad idea to blog about it – it my help some other soul to learn about and get excited about building Windows 7 phone applications, or perhaps it might be useful for me to cover other topics in the future in my blogs. So here it is – a step by step tutorial of developing my first Windows Phone application!</font></p>  <h3><font size="2"></font></h3>  <h2></h2>  <h1>Get Visual Studio 2010, and download Silverlight for Windows Phone</h1>  <p><font size="2">I am assuming you already have a developer edition Visual Studio 2010 (you can get more details about the product <a href="http://www.microsoft.com/visualstudio/en-us/try?CR_CC=200000862&amp;WT.mc_id=MSCOM_MEDIA&amp;WT.mc_id=MSCOM_HP_US_BIZ_113LMUS004262">here</a>). </font><font size="2">You also need to download the Silverlight for Windows Phone package – Silverlight being the application development platform for Windows Phone 7. You can get it <a href="http://www.silverlight.net/getstarted/devices/windows-phone/">here</a>. From there you also need to download the Windows Phone 7 developer toolkit, that plugs into Visual Studio.</font></p>  <p><font size="2">I am now set to create the first Windows phone application. </font></p>  <p><font size="2">I will start with building a simple Stopwatch application. This type of application is already readily available in many forms in the Windows Marketplace – but as I said, the goal for this post is to just get started with a simple application. I will call this application a Chronometer – maybe I will add more functionality later.</font></p>  <p>&#160;</p>  <h1>Creating a new project, leveraging the template</h1>  <p><font size="2">Creating the shell of the application is real easy – simple create a new project in Visual Studio and choose to create a Windows Phone Application – that’s all! Check out some screen shots below.</font></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6406.image_36B7787A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6406.image_5F00_36B7787A.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8171.image_thumb_5ACCAD3C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/8171.image_5F00_thumb_5F00_5ACCAD3C.png" width="504" height="327" /></a></p>  <p>&#160;</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0537.image_2FC4996A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0537.image_5F00_2FC4996A.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7802.image_thumb_6C68A9D5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7802.image_5F00_thumb_5F00_6C68A9D5.png" width="504" height="242" /></a></p>  <p><font size="2">You can just build and run the application. The application comes up in the simulator, and is pretty functional already – see the screens below! The one of the left gives you a default view of the application we are building – it has a default title for the application, and a default name for the starting page of the application. The simulator also includes fully functional buttons that you’d have on the phone. Clicking on the &quot;windows” button shows you the start screen of the phone, complete with a tile for internet explorer (and that tile/app is fully functional too). Clicking on the navigation button next to the IE tile, you see the third screen which shows the applications already on the phone – and here you see that our chronometer application has also shown up (we should change the tile of the application here – it has simply picked up the title of the solution we have created in Visual Studio. Finally, you can click on the search button on the phone, and it brings up the Bing search application – once again, fully functional including the current day’s Bing picture and fully functional voice search capability. I love the Windows Phone 7 simulator in Visual Studio – it not only makes building your application really easy, but allows you to get a feel for it in an actual environment by giving a pretty functional feel of the Windows Phone 7 device!</font></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4377.image_7377C080.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4377.image_5F00_7377C080.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5466.image_thumb_1720C24E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5466.image_5F00_thumb_5F00_1720C24E.png" width="154" height="285" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5775.image_4D423A9D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5775.image_5F00_4D423A9D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4721.image_thumb_62FBFD2D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4721.image_5F00_thumb_5F00_62FBFD2D.png" width="154" height="285" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3568.image_4B151607.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/3568.image_5F00_4B151607.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5228.image_thumb_18A11CBB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5228.image_5F00_thumb_5F00_18A11CBB.png" width="154" height="285" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0434.image_5C94DB05.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0434.image_5F00_5C94DB05.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0434.image_thumb_2094AB1E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0434.image_5F00_thumb_5F00_2094AB1E.png" width="154" height="285" /></a></p>  <h1></h1>          <h1>Few easy modifications to begin with – change the application name and titles</h1>  <p><font size="2">Getting back to Visual Studio, you can see the XAML representation for the UI and the actual view displayed in the designer mode. You can simply click on the controls, check out their properties on the bottom-right of the screen, and change the texts. For example, I have changed the title of the application and the title of the main page below. I will build a stopwatch application for the main page. </font></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3823.image_5C90C706.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/3823.image_5F00_5C90C706.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7658.image_thumb_65E939E2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7658.image_5F00_thumb_5F00_65E939E2.png" width="504" height="300" /></a></p>  <p><font size="2">Let us also change the name of the application that shows up in the list of applications on the phone. Click on the name of the solution in the solutions explorer, and bring up the properties page. Click on the applications tab in the properties and change both the title in the “deployment” as well as the “Tile” options property sets – see below.</font></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1665.image_2CC23713.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1665.image_5F00_2CC23713.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4401.image_thumb_2DB6D498.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4401.image_5F00_thumb_5F00_2DB6D498.png" width="504" height="302" /></a></p>  <p><font size="2">Simply build and run the application again, and you can see all of the changes have been effected. Including the tilt of the application in the tile view (I simply double clicked on the application in the list on the left screen and pinned it to the start page).</font> </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7571.image_16C7DD4F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7571.image_5F00_16C7DD4F.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7870.image_thumb_5C98C4D5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7870.image_5F00_thumb_5F00_5C98C4D5.png" width="154" height="285" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6825.image_12BA3D25.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6825.image_5F00_12BA3D25.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5857.image_thumb_2BA5E79D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5857.image_5F00_thumb_5F00_2BA5E79D.png" width="154" height="283" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1072.image_6F2D72F2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1072.image_5F00_6F2D72F2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3632.image_thumb_3E3A95BA.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/3632.image_5F00_thumb_5F00_3E3A95BA.png" width="154" height="287" /></a></p>  <p><font size="2">It is worth reflecting on how easy Visual Studio makes developing Windows Phone applications too! With just a few very simple steps we have created the structure of the application.</font></p>  <h1></h1>  <h1></h1>  <h1></h1>  <h1></h1>      <h1>Creating the Stopwatch display</h1>  <p><font size="2">Let’s now get to the core of our application. I will first add the main display for the Stopwatch page. I intend to be in the format of “DD:HH:MM:SS:mmm” displaying days, hours, minutes, and milliseconds.</font></p>  <p><font size="2">Back in Visual Studio, bring down the toolbox of controls that you can choose from (via View.Toolbox menu) – see below. You have a rich set of controls to choose from.</font> </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3124.image_171FD678.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/3124.image_5F00_171FD678.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1488.image_thumb_018189DC.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1488.image_5F00_thumb_5F00_018189DC.png" width="504" height="302" /></a></p>  <p><font size="2">I am choosing the “Textbox” control for the main display – it allows me to display a rich text on the page. You simply double click the control from the Toolbox to get it on to the application page. Next, simply change the properties (I have changed the display text to be 00:00:00:000 by default, and have changed the font size to 64), resize the control to the desired size, and drag and position it to the location you want.</font></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0218.image_739F1E13.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0218.image_5F00_739F1E13.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5187.image_thumb_2AD4BDDB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5187.image_5F00_thumb_5F00_2AD4BDDB.png" width="504" height="300" /></a></p>  <p><font size="2">The application display now looks as shown below. I now would like to add a start/pause button to finalize my first page for my simple Stopwatch application. For this, I simply create two icons – for play (or start) and pause – and create two JPG files for them. I used Windows Paint to create these two icons – each being a 60x60 in pixel size. I then add those two files to my solution via “Project.Add Existing Item…” menu</font></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6433.image_4354355E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6433.image_5F00_4354355E.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3302.image_thumb_1C464991.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/3302.image_5F00_thumb_5F00_1C464991.png" width="154" height="285" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4382.image_7935D820.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4382.image_5F00_7935D820.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2335.image_thumb_0C0A5BCB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/2335.image_5F00_thumb_5F00_0C0A5BCB.png" width="229" height="121" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7853.image_5B93D754.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7853.image_5F00_5B93D754.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6064.image_thumb_78B97F5E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6064.image_5F00_thumb_5F00_78B97F5E.png" width="244" height="226" /></a></p>  <p><font size="2">Next, I add a button from the Toolbox to the application screen, position it and size it appropriately. At this point this is a simple button, and the page and the backing XAML looks as follows.</font></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5430.image_7C77242E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5430.image_5F00_7C77242E.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7433.image_thumb_72AE6A5E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7433.image_5F00_thumb_5F00_72AE6A5E.png" width="504" height="225" /></a></p>  <p><font size="2">However, instead of the Button being a simple Text button, I want the button to use an image – say the “play” image that I have created above. To do this, I simply add the “Image” tag to the Button definition directly in the XAML file shown above. The reworked XAML looks as follows – notice the &lt;Image /&gt; tag in the XML inserted in the definition of the &lt;Button /&gt; tag, and also that the play icon now shows up in the Button – we have transformed it into a an image based button.</font></p>  <p><font size="2">With this, we have really completed our application layout! Now we need to add a bit of code for the Stopwatch logic.</font></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/8865.image_0C727AC1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/8865.image_5F00_0C727AC1.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4113.image_thumb_2A208D5B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4113.image_5F00_thumb_5F00_2A208D5B.png" width="504" height="283" /></a></p>                <h1>Adding the code for the Stopwatch</h1>  <p><font size="2">As you can imagine, all of the action will be initiated by the clicking of the play button. To create an event handler for the button, simply double click on the button in the display view for the XAML for the main page. It creates the following code in the backing code file.</font></p>  <p>&#160;</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3531.image_58C5FA63.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/3531.image_5F00_58C5FA63.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4113.image_thumb_77303B4C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4113.image_5F00_thumb_5F00_77303B4C.png" width="504" height="100" /></a></p>  <p><font size="2">Now we will simply add the code in the event handler framework that has been created by Visual Studio.</font></p>  <p><font size="2">My focus here is not to write the most efficient code, but will rather focus on simplicity.</font></p>  <h1></h1>  <h3>Adding class references </h3>  <p><font size="2">We will be using few special class from the System name space – namely Media for updating the image of the button, Threading to get a timer going, and Diagnostics to use the Stopwatch object built into .NET. I start of by adding these references in the MainPage.xaml.cs file</font></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0312.image_7FD093D8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0312.image_5F00_7FD093D8.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0728.image_thumb_3E55E17F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0728.image_5F00_thumb_5F00_3E55E17F.png" width="244" height="53" /></a>&#160;</p>  <h2></h2>  <h2>A few member variables </h2>  <p><font size="2">I next introduce a few member variables. These will store the day/hour/minute/second/millisecond values that I will display; the state of the stopwatch (started or paused) , a Stopwatch object, and a Timer object ;</font></p>  <p><font size="2">It also created two BitmapImage objects for the start and pause images that the button will display.</font></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7762.image_09D50F37.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7762.image_5F00_09D50F37.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/7183.image_thumb_6E500D33.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/7183.image_5F00_thumb_5F00_6E500D33.png" width="504" height="127" /></a></p>  <h3>The start/pause click logic</h3>  <p><font size="2">Now, we move onto the code which executes when the play button is clicked. Note, this button is going to toggle between “start” and “pause” modes.</font></p>  <p><font size="2">When in the stopped state (the initial state), it toggles the state, sets the image in the button to the pause button, creates a new Timer object, and also starts the stopwatch timer in code. </font></p>  <p><font size="2">The Timer object is created with a callback method (updateDisplay) which we will discuss shortly. It also sets up the callback to be called with a reference to our TimerDisplay TextBlock so that we can update it. The penultimate parameter of 0 starts the timer straightway, and the last parameter of 100 sets it up to call the callback function at intervals of 100 milliseconds.</font></p>  <p><font size="2">The logic is similar and simple when the stopped state is false – it changes the image of the button to play, disposes the timer, and stops the stopwatch. Note that in our application, the stopwatch can be resumed from the point of pausing by clicking play again.</font></p>  <p>The code is shown below.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0456.image_364E1950.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0456.image_5F00_364E1950.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3414.image_thumb_2FBA99C0.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/3414.image_5F00_thumb_5F00_2FBA99C0.png" width="504" height="285" /></a></p>    <h3>The Timer callback</h3>  <p><font size="2">Finally, we are ready to plug in the last piece of code – the callback function – which will update the applications display.</font></p>  <p><font size="2">The code is shown below. </font></p>  <p><font size="2">We simply calculate the elapsed time from Stopwatch object, convert it into the appropriate formatted display string for the application</font></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2821.image_70996964.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/2821.image_5F00_70996964.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/0361.image_thumb_0E2B4464.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/0361.image_5F00_thumb_5F00_0E2B4464.png" width="504" height="131" /></a></p>  <h3>The application is ready!</h3>  <p><font size="2">With that, our app is ready! Simply build and run the application, to check it out on the Simulator. I show four screens below – the application listed in the list of applications, the starting screen, once the start button is clicked, and once the pause button is clicked</font></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1781.image_6B1AD2F3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1781.image_5F00_6B1AD2F3.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/5516.image_thumb_181F99F5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/5516.image_5F00_thumb_5F00_181F99F5.png" width="154" height="287" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/4885.image_750F2884.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/4885.image_5F00_750F2884.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/1754.image_thumb_0E56E025.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/1754.image_5F00_thumb_5F00_0E56E025.png" width="154" height="285" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2843.image_0B617B72.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/2843.image_5F00_0B617B72.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/6866.image_thumb_167ADFEF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/6866.image_5F00_thumb_5F00_167ADFEF.png" width="154" height="283" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/2262.image_2876FDAF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/2262.image_5F00_2876FDAF.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/15/68/metablogapi/3755.image_thumb_012C8EAD.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-15-68-metablogapi/3755.image_5F00_thumb_5F00_012C8EAD.png" width="154" height="285" /></a></p>  <h3></h3>            <h3>What’s next?</h3>  <p><font size="2">That was fun – and not bad, for a Saturday afternoon’s worth of coding. Visual Studio really does make building Windows 7 Phone applications quite easy.</font></p>  <p><font size="2">So, what’s next? </font></p>  <p><font size="2">There are many different ways I could extend this work – I could add more functionality to the stopwatch, or perhaps I could add another page to the application and add another functionality to the chronometer (may be a count down timer?). A demonstration of an application with two pages would be a good learning! And then of course there is the task of actually deploying the application to the app store, Perhaps I could also go into testing of phone applications. So, there are lots of ways I could take this – will wait for another lazy afternoon.</font></p>  <p><font size="2">Cheers!</font></p>]]></content:encoded>
    </item>
  </channel>
</rss>