<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>DotNETForDevices</title>
	<atom:link href="http://mstruys.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mstruys.com</link>
	<description>Windows Phone Application Development</description>
	<lastBuildDate>Mon, 06 Aug 2012 07:25:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='mstruys.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/af2765725ba464707907068ba99d40d2?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>DotNETForDevices</title>
		<link>http://mstruys.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://mstruys.com/osd.xml" title="DotNETForDevices" />
	<atom:link rel='hub' href='http://mstruys.com/?pushpress=hub'/>
		<item>
		<title>AdControl, Animations and the Back Key</title>
		<link>http://mstruys.com/2012/05/19/adcontrol-animations-and-the-back-key/</link>
		<comments>http://mstruys.com/2012/05/19/adcontrol-animations-and-the-back-key/#comments</comments>
		<pubDate>Sat, 19 May 2012 14:29:52 +0000</pubDate>
		<dc:creator>Maarten Struys</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[AdControl]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[Hardware back button]]></category>

		<guid isPermaLink="false">https://mstruys.wordpress.com/?p=388</guid>
		<description><![CDATA[Sometimes things don’t make sense, but bugs in software hardly do. In a new Windows Phone application I am implementing a fully functional trial mode that displays advertisements using Microsoft’s AdControl. I made sure to use the latest version of the AdControl (which is version 6.1.320.0). On one of the pages inside the application has [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=388&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Sometimes things don’t make sense, but bugs in software hardly do. In a new Windows Phone application I am implementing a fully functional trial mode that displays advertisements using Microsoft’s <a href="http://msdn.microsoft.com/en-us/library/advertising-mobile-windows-phone-adcontrol-silverlight-class(v=msads.20).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">AdControl</a>. I made sure to use the latest version of the <a href="http://www.microsoft.com/en-us/download/details.aspx?id=8729" target="_blank">AdControl (which is version 6.1.320.0)</a>. On one of the pages inside the application has both a list and detail view. If an item is selected from a list, the list disappears in the center of the page and detail information zooms in, making use of a few animations. Since the detail view seems to be a new page (even though it isn’t), I am overriding default <a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.controls.phoneapplicationpage.onbackkeypress(v=VS.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">hardware Back button</a> behavior. If details are displayed when the hardware Back button is pressed, the list view becomes visible again. If the list view was already visible, I simply navigate back to the previous page. All in all, this functionality is straight forward and it is not uncommon to reuse pages for different views.</p>
<p>However, when I was testing the application, I ran into some unexpected behavior. With the AdControl visible, the animation that was supposed to run on pressing the hardware Back button did not run smoothly and sometimes it didn’t run at all. However, with the AdControl not visible, the animation was always running nice and smoothly. </p>
<p>This code is executed on pressing the hardware Back button:</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2503f001-361a-4480-be20-b6c3de2168b6" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Switching from detail to list</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">override</span> <span style="color:#0000ff;">void</span> OnBackKeyPress(<span style="color:#2b91af;">CancelEventArgs</span> e)</li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#0000ff;">if</span> (lastActiveListBox != <span style="color:#0000ff;">null</span>)</li>
<li style="background:#f3f3f3;">    {</li>
<li>        e.Cancel = <span style="color:#0000ff;">true</span>;</li>
<li style="background:#f3f3f3;">        lastActiveListBox = <span style="color:#0000ff;">null</span>;</li>
<li>        <span style="color:#2b91af;">VisualStateManager</span>.GoToState(<span style="color:#0000ff;">this</span>, <span style="color:#a31515;">&quot;TreeListState&quot;</span>, <span style="color:#0000ff;">true</span>);</li>
<li style="background:#f3f3f3;">    }</li>
<li>    <span style="color:#0000ff;">base</span>.OnBackKeyPress(e);</li>
<li style="background:#f3f3f3;">}</li>
</ol></div>
</p></div>
</p></div>
<p>The following video shows the application in action, once with an AdControl on the page and once without the AdControl:</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:01eb7cf4-d38e-4cef-b86f-8dad9fccfc62" class="wlWriterEditableSmartContent">
<div><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='448' height='252' src='http://www.youtube.com/embed/Qyn5gFuyYCM?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;hd=1&#038;wmode=transparent' frameborder='0'></iframe></span></div>
<div style="width:448px;clear:both;font-size:.8em;">The AdControl influences animations</div>
</div>
<p>Of course this behavior is unacceptable for my application, so the next step is trying to work around the issue. After investigating a bit further, it seems that the combination of showing an AdControl and triggering an animation on the hardware Back button causes the problem. For instance, executing exactly the same code, but this time when tapping on the title bar (after adding a tap event handler), always results in smooth animations, independent of displaying an AdControl. </p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:43874695-72b4-40dc-a1de-397fae01f98a" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">override</span> <span style="color:#0000ff;">void</span> OnBackKeyPress(<span style="color:#2b91af;">CancelEventArgs</span> e)</li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#0000ff;">if</span> (lastActiveListBox != <span style="color:#0000ff;">null</span>)</li>
<li style="background:#f3f3f3;">    {</li>
<li>        e.Cancel = <span style="color:#0000ff;">true</span>;</li>
<li style="background:#f3f3f3;">        lastActiveListBox = <span style="color:#0000ff;">null</span>;</li>
<li>        <span style="color:#2b91af;">VisualStateManager</span>.GoToState(<span style="color:#0000ff;">this</span>, <span style="color:#a31515;">&quot;TreeListState&quot;</span>, <span style="color:#0000ff;">true</span>);</li>
<li style="background:#f3f3f3;">    }</li>
<li>    <span style="color:#0000ff;">base</span>.OnBackKeyPress(e);</li>
<li style="background:#f3f3f3;">}</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> ApplicationTitle_Tap(<span style="color:#0000ff;">object</span> sender, System.Windows.Input.<span style="color:#2b91af;">GestureEventArgs</span> e)</li>
<li>{</li>
<li style="background:#f3f3f3;">    <span style="color:#0000ff;">if</span> (lastActiveListBox != <span style="color:#0000ff;">null</span>)</li>
<li>    {</li>
<li style="background:#f3f3f3;">        lastActiveListBox = <span style="color:#0000ff;">null</span>;</li>
<li>        <span style="color:#2b91af;">VisualStateManager</span>.GoToState(<span style="color:#0000ff;">this</span>, <span style="color:#a31515;">&quot;TreeListState&quot;</span>, <span style="color:#0000ff;">true</span>);</li>
<li style="background:#f3f3f3;">    }</li>
<li>}</li>
</ol></div>
</p></div>
</p></div>
<p>Triggering the animation on the hardware Back button still shows the same behavior though:</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:d5c173e4-0506-441e-a78d-63f2bed2b4d3" class="wlWriterEditableSmartContent">
<div><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='448' height='252' src='http://www.youtube.com/embed/N3s1x3kWM1I?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;hd=1&#038;wmode=transparent' frameborder='0'></iframe></span></div>
<div style="width:448px;clear:both;font-size:.8em;">The AdControl in combination with the Back Key influences animations</div>
</div>
<p>I am not sure what causes the problem. However, the fact that the animation runs smoothly when triggered in another way got me thinking about a more or less acceptable work around with not too much additional code involved. Since starting the animation on another event got rid of my problem, I came to the following solution. When the hardware Back button is pressed in my detailed view, I start a <a href="http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatchertimer(v=vs.95).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">Timer</a> that expires immediately. In the Tick event of the timer I am simply stopping the timer and I am starting the animation. This resulted in the following code:</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2b1ba9ea-28df-4750-a411-919caf3eede7" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Start animation on timer tick</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#0000ff;">private</span> <span style="color:#2b91af;">DispatcherTimer</span> timer;</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li><span style="color:#0000ff;">public</span> TreePage()</li>
<li style="background:#f3f3f3;">{</li>
<li>    InitializeComponent();</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>    <span style="color:#0000ff;">if</span> (<span style="color:#2b91af;">App</span>.ShowAds)</li>
<li style="background:#f3f3f3;">    {</li>
<li>        timer = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">DispatcherTimer</span>();</li>
<li style="background:#f3f3f3;">        timer.Tick += <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">EventHandler</span>(timer_Tick);</li>
<li>        ah = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">AdHelper</span>(AdPlaceHolder, <span style="color:#0000ff;">true</span>);</li>
<li style="background:#f3f3f3;">        <span style="color:#0000ff;">this</span>.Loaded += <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">RoutedEventHandler</span>(ah.PhoneApplicationPage_Loaded);</li>
<li>    }</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>}</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li><span style="color:#0000ff;">void</span> timer_Tick(<span style="color:#0000ff;">object</span> sender, <span style="color:#2b91af;">EventArgs</span> e)</li>
<li style="background:#f3f3f3;">{</li>
<li>    timer.Stop();</li>
<li style="background:#f3f3f3;">    <span style="color:#2b91af;">VisualStateManager</span>.GoToState(<span style="color:#0000ff;">this</span>, <span style="color:#a31515;">&quot;TreeListState&quot;</span>, <span style="color:#0000ff;">true</span>);</li>
<li>}</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li><span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">override</span> <span style="color:#0000ff;">void</span> OnBackKeyPress(<span style="color:#2b91af;">CancelEventArgs</span> e)</li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#0000ff;">if</span> (lastActiveListBox != <span style="color:#0000ff;">null</span>)</li>
<li style="background:#f3f3f3;">    {</li>
<li>        e.Cancel = <span style="color:#0000ff;">true</span>;</li>
<li style="background:#f3f3f3;">        lastActiveListBox = <span style="color:#0000ff;">null</span>;</li>
<li>        <span style="color:#0000ff;">if</span> (<span style="color:#2b91af;">App</span>.ShowAds)</li>
<li style="background:#f3f3f3;">        {</li>
<li>            timer.Start();</li>
<li style="background:#f3f3f3;">        }</li>
<li>        <span style="color:#0000ff;">else</span></li>
<li style="background:#f3f3f3;">        {</li>
<li>            <span style="color:#2b91af;">VisualStateManager</span>.GoToState(<span style="color:#0000ff;">this</span>, <span style="color:#a31515;">&quot;TreeListState&quot;</span>, <span style="color:#0000ff;">true</span>);</li>
<li style="background:#f3f3f3;">        }</li>
<li>    }</li>
<li style="background:#f3f3f3;">    <span style="color:#0000ff;">base</span>.OnBackKeyPress(e);</li>
<li>}</li>
</ol></div>
</p></div>
</p></div>
<p>This time the animation displays smoothly, independent of the presence or absence of an AdControl as is shown in the following video:</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:fd416b85-d88b-43a5-a26c-7dfb595b70dc" class="wlWriterEditableSmartContent">
<div><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='448' height='252' src='http://www.youtube.com/embed/8mK_LilmeFw?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;hd=1&#038;wmode=transparent' frameborder='0'></iframe></span></div>
<div style="width:448px;clear:both;font-size:.8em;">Animations are smooth when started on a Timer Tick</div>
</div>
<p>It would have been great if I could have explained why the AdControl in combination with the hardware Back button influences animations. For right now I assume this is a bug in the AdControl. At least, the work around shown in the blog entry is relatively simple and is not a big influence on either the memory footprint or the performance of your Windows Phone application. When a new version of the AdControl is available, I will make sure to test the identical scenario again and update this blog entry when results have changed.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mstruys.wordpress.com/388/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mstruys.wordpress.com/388/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=388&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mstruys.com/2012/05/19/adcontrol-animations-and-the-back-key/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef2225df699c5c8ad7ed7c0287d87b41?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mstruys</media:title>
		</media:content>
	</item>
		<item>
		<title>EvenTiles and Push Notifications</title>
		<link>http://mstruys.com/2012/04/25/eventiles-and-push-notifications/</link>
		<comments>http://mstruys.com/2012/04/25/eventiles-and-push-notifications/#comments</comments>
		<pubDate>Wed, 25 Apr 2012 15:52:44 +0000</pubDate>
		<dc:creator>Maarten Struys</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[Windows Phone SDK 7.1]]></category>
		<category><![CDATA[Windows Phone SDK 7.1.1 Update]]></category>
		<category><![CDATA[Push Notifications]]></category>
		<category><![CDATA[Tile Notifications]]></category>

		<guid isPermaLink="false">https://mstruys.wordpress.com/?p=374</guid>
		<description><![CDATA[In the previous part of EvenTiles, you saw that applications running on 256-MB Devices cannot use Periodic Agents. Of course the application is still working, but the content of the backside of a Secondary Tile, when pinned to the start screen, does not alter. Since 256-MB Windows Phone Devices fully support Push Notifications, it is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=374&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In the <a href="https://mstruys.wordpress.com/2012/04/19/eventiles-and-256-mb-windows-phone-devices/" target="_blank">previous part of EvenTiles</a>, you saw that applications running on 256-MB Devices cannot use Periodic Agents. Of course the application is still working, but the content of the backside of a Secondary Tile, when pinned to the start screen, does not alter. Since 256-MB Windows Phone Devices fully support <a href="http://msdn.microsoft.com/en-us/library/ff402558(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">Push Notifications</a>, it is possible to change the Secondary Tile content with a little extra effort. In this episode of EvenTiles we will take a look at adding Tile Notifications to the application. Those Tile Notifications are delivered to individual Windows Phone devices through the Microsoft Push Notification Service, just like all other Push Notifications.</p>
<p>In this blog entry we will concentrate on the client side, mainly providing code that registers the application. To test the application, we will make use of a little ASP.NET application that is based on the sample that is introduced in the <a href="http://msdn.microsoft.com/en-us/library/hh202970(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank"><em>How to Send and Receive Tile Notifications for Windows Phone</em></a> article. It is beyond the scope of this blog entry to show how to host a web service (for instance by making use of Azure functionality).</p>
<blockquote><p><strong>NOTE:</strong> The ASP.NET test application cannot be created using Visual Studio 2010 Express for Windows Phone. You either need at least Visual Studio 2010 Professional or the free <a href="http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-web-developer-express?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">Visual Web Developer 2010 Express</a> to create the test application.</p>
</blockquote>
<h5>Push Notifications on Secondary Tiles</h5>
<p>Something that is not entirely clear in the referred <em>How to</em> article, or in the documentation around Push Notifications on MSDN is the fact that sending Tile Updates through Push Notifications is not limited to the Application Tile, but you can also use the same approach to update Secondary Tiles. Since we are dealing with a Secondary Tile in the EvenTiles application, we will focus on updating a Secondary Tile. In the ASP.NET test application we will create the following message to update our tile:</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3e3dc024-1601-4dbb-8709-bb7ac14296ad" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Updating a Seondary Tile</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#008000;">// Create the Tile message.</span></li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">string</span> tileMessage = <span style="color:#a31515;">&quot;&lt;?xml version=&#092;&quot;1.0&#092;&quot; encoding=&#092;&quot;utf-8&#092;&quot;?&gt;&quot;</span> +</li>
<li><span style="color:#a31515;">&quot;&lt;wp:Notification xmlns:wp=&#092;&quot;WPNotification&#092;&quot;&gt;&quot;</span> +</li>
<li style="background:#f3f3f3;">    <span style="color:#a31515;">&quot;&lt;wp:Tile ID=&#092;&quot;/MainPage.xaml?TileId=Secondary&#092;&quot;&gt;&quot;</span> +</li>
<li>      <span style="color:#a31515;">&quot;&lt;wp:BackContent&gt;&quot;</span> + TextBoxBackContent.Text + <span style="color:#a31515;">&quot;&lt;/wp:BackContent&gt;&quot;</span> +</li>
<li style="background:#f3f3f3;">      <span style="color:#a31515;">&quot;&lt;wp:Count&gt;&quot;</span> + nrRuns.ToString() + <span style="color:#a31515;">&quot;&lt;/wp:Count&gt;&quot;</span> +</li>
<li>   <span style="color:#a31515;">&quot;&lt;/wp:Tile&gt; &quot;</span> +</li>
<li style="background:#f3f3f3;"><span style="color:#a31515;">&quot;&lt;/wp:Notification&gt;&quot;</span>;</li>
</ol></div>
</p></div>
</p></div>
<p>By explicitly specifying the ID of a tile you can inform the Push Notification Service that you want to update a specific (Secondary) Tile. Omitting the ID passes the update to the Application Tile. Since EvenTiles creates the Secondary Tile as shown below, passing the Tile Notification message as shown above will update the Secondary Tile if it is pinned to the Start Screen. In the sample we only update the BackContent of the Secondary Tile and the count on the front of it, but it is possible to update more properties of the Secondary Tile. Of course it is important to use the same URI for the Secondary Live Tile when updating it through a Tile Notification.</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:549dd95b-252f-44bb-8bff-a993c5af207a" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Creating a Secondary Tile</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> btnInstall_Click(<span style="color:#0000ff;">object</span> sender, <span style="color:#2b91af;">RoutedEventArgs</span> e)</li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#2b91af;">StandardTileData</span> NewTileData = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">StandardTileData</span></li>
<li style="background:#f3f3f3;">    {</li>
<li>        BackgroundImage = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">Uri</span>(<span style="color:#a31515;">&quot;Background.png&quot;</span>, <span style="color:#2b91af;">UriKind</span>.Relative),</li>
<li style="background:#f3f3f3;">        Title = <span style="color:#a31515;">&quot;EvenTiles&quot;</span>,</li>
<li>        Count = 0,</li>
<li style="background:#f3f3f3;">        BackBackgroundImage = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">Uri</span>(<span style="color:#a31515;">&quot;BackBackTile.png&quot;</span>, <span style="color:#2b91af;">UriKind</span>.Relative),</li>
<li>        BackTitle = <span style="color:#a31515;">&quot;EvenTiles&quot;</span>,</li>
<li style="background:#f3f3f3;">        BackContent = <span style="color:#2b91af;">App</span>.ActualSecBackContent</li>
<li>    };</li>
<li style="background:#f3f3f3;">    <span style="color:#2b91af;">ShellTile</span>.Create(<span style="color:#0000ff;">new</span> <span style="color:#2b91af;">Uri</span>(<span style="color:#a31515;">&quot;/MainPage.xaml?TileId=Secondary&quot;</span>, <span style="color:#2b91af;">UriKind</span>.Relative), NewTileData);</li>
<li>}</li>
</ol></div>
</p></div>
</p></div>
<p>In order to receive Tile Notifications in EvenTiles, the application needs to create a <a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.notification.httpnotificationchannel(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">HttpNotificationChannel</a> or attach to an already created channel if the application is started again on a particular Windows Phone device. The following code snippet shows how to setup a new notification channel. If the channel is successfully opened, it will pass a URI through the <a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.notification.httpnotificationchannel.channeluriupdated(v=VS.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">ChannelUriUpdated</a> event handler. This URI is used to send notifications to the particular Windows Phone Device that received this URI from the Push Notification Service. This URI is unique for the application and the phone on which the application is running. If the channel already exists, this method simply starts listening for channel changes or errors through the ChannelUriUpdated and <a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.notification.httpnotificationchannel.erroroccurred(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">ErrorOccurred</a> events respectively.</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:59a05a7a-b693-4d9a-b820-44cf8b38ed7c" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Getting a Notification Channel</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">TileNotifications</span></li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">const</span> <span style="color:#0000ff;">string</span> tileNotificationChannel = <span style="color:#a31515;">&quot;EvenTilesChannel&quot;</span>;</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>    <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> SetupChannel()</li>
<li style="background:#f3f3f3;">    {</li>
<li>        <span style="color:#0000ff;">var</span> pushChannel = <span style="color:#2b91af;">HttpNotificationChannel</span>.Find(tileNotificationChannel);</li>
<li style="background:#f3f3f3;">        <span style="color:#0000ff;">if</span> (pushChannel == <span style="color:#0000ff;">null</span>)</li>
<li>        {</li>
<li style="background:#f3f3f3;">            pushChannel = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">HttpNotificationChannel</span>(tileNotificationChannel);</li>
<li>            pushChannel.ChannelUriUpdated += <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">EventHandler</span>&lt;<span style="color:#2b91af;">NotificationChannelUriEventArgs</span>&gt;(PushChannel_ChannelUriUpdated);</li>
<li style="background:#f3f3f3;">            pushChannel.ErrorOccurred += <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">EventHandler</span>&lt;<span style="color:#2b91af;">NotificationChannelErrorEventArgs</span>&gt;(PushChannel_ErrorOccurred);</li>
<li>            pushChannel.Open();</li>
<li style="background:#f3f3f3;">            pushChannel.BindToShellTile();</li>
<li>        }</li>
<li style="background:#f3f3f3;">        <span style="color:#0000ff;">else</span></li>
<li>        {</li>
<li style="background:#f3f3f3;">            pushChannel.ChannelUriUpdated += <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">EventHandler</span>&lt;<span style="color:#2b91af;">NotificationChannelUriEventArgs</span>&gt;(PushChannel_ChannelUriUpdated);</li>
<li>            pushChannel.ErrorOccurred += <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">EventHandler</span>&lt;<span style="color:#2b91af;">NotificationChannelErrorEventArgs</span>&gt;(PushChannel_ErrorOccurred);</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>            <span style="color:#008000;">// Display the URI for testing purposes. Normally, the URI would be passed back to a web service.</span></li>
<li style="background:#f3f3f3;">            System.Diagnostics.<span style="color:#2b91af;">Debug</span>.WriteLine(pushChannel.ChannelUri.ToString());</li>
<li>        }</li>
<li style="background:#f3f3f3;">    }</li>
</ol></div>
</p></div>
</p></div>
<p>If you want to send out push notifications from a web service, the Windows Phone application typically would send this URI to a web service, that in turn uses it to deliver the push notifications to the registered device. In our test application we simply display the URI in the debug windows of Visual Studio to be able to copy it to our ASP.NET test application.</p>
<p>If you are no longer interested in receiving Tile Notifications for your application, you can close a previously opened HttpNotificationChannel, make sure to dispose of it and also make sure to unsubscribe to events to prevent against leaking memory. The following code snippet shows how you can stop receiving Tile Notifications:</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ee260b1e-7dd3-4a0f-bbcf-de5ea84e5745" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Closing a Notification Channel</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> CloseChannel()</li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#0000ff;">var</span> pushChannel = <span style="color:#2b91af;">HttpNotificationChannel</span>.Find(tileNotificationChannel);</li>
<li style="background:#f3f3f3;">    <span style="color:#0000ff;">if</span> (pushChannel != <span style="color:#0000ff;">null</span>)</li>
<li>    {</li>
<li style="background:#f3f3f3;">        pushChannel.ChannelUriUpdated -= PushChannel_ChannelUriUpdated;</li>
<li>        pushChannel.ErrorOccurred -= PushChannel_ErrorOccurred;</li>
<li style="background:#f3f3f3;">        pushChannel.Close();</li>
<li>        pushChannel.Dispose();</li>
<li style="background:#f3f3f3;">        <span style="color:#2b91af;">App</span>.GetLiveTileNotifications = <span style="color:#0000ff;">false</span>;</li>
<li>    }</li>
<li style="background:#f3f3f3;">}</li>
</ol></div>
</p></div>
</p></div>
<p>Finally, in our EvenTiles application we implement some simplified event handling to react on push channel changes and errors. This implementation is for demonstration purposes only and can be used to manually pass a channel URI to an ASP.NET application or to close down / reinitialize the push channel on certain errors. The following code snippet shows how we simply write the channel URI to the Output Window of Visual Studio.</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2a6cfd1a-5d65-4bbe-9590-ca2b0f99abfc" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Handling Push Channel Events</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#0000ff;">void</span> PushChannel_ErrorOccurred(<span style="color:#0000ff;">object</span> sender, <span style="color:#2b91af;">NotificationChannelErrorEventArgs</span> e)</li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#0000ff;">switch</span> (e.ErrorType)</li>
<li style="background:#f3f3f3;">    {</li>
<li>        <span style="color:#0000ff;">case</span> <span style="color:#2b91af;">ChannelErrorType</span>.ChannelOpenFailed:</li>
<li style="background:#f3f3f3;">            <span style="color:#2b91af;">App</span>.GetLiveTileNotifications = <span style="color:#0000ff;">false</span>;</li>
<li>            <span style="color:#0000ff;">break</span>;</li>
<li style="background:#f3f3f3;">        <span style="color:#0000ff;">case</span> <span style="color:#2b91af;">ChannelErrorType</span>.PayloadFormatError:</li>
<li>            SetupChannel();</li>
<li style="background:#f3f3f3;">            <span style="color:#0000ff;">break</span>;</li>
<li>        <span style="color:#0000ff;">default</span>:</li>
<li style="background:#f3f3f3;">            CloseChannel();</li>
<li>            <span style="color:#0000ff;">break</span>;</li>
<li style="background:#f3f3f3;">    }</li>
<li>}</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li><span style="color:#0000ff;">void</span> PushChannel_ChannelUriUpdated(<span style="color:#0000ff;">object</span> sender, <span style="color:#2b91af;">NotificationChannelUriEventArgs</span> e)</li>
<li style="background:#f3f3f3;">{</li>
<li>    System.Diagnostics.<span style="color:#2b91af;">Debug</span>.WriteLine(e.ChannelUri.ToString());</li>
<li style="background:#f3f3f3;">    <span style="color:#2b91af;">App</span>.GetLiveTileNotifications = <span style="color:#0000ff;">true</span>;</li>
<li>}</li>
</ol></div>
</p></div>
</p></div>
<p><a href="http://mstruys.files.wordpress.com/2012/04/image3.png"><img style="margin:0 10px 2px 0;display:inline;float:left;" title="image" alt="image" align="left" src="http://mstruys.files.wordpress.com/2012/04/image_thumb3.png?w=240&#038;h=141" width="240" height="141" /></a>To send Tile Notifications to EvenTiles, make sure to run EvenTiles and enable Tile Notifications through the Settings Page. Once Tile Notifications are enabled, you can copy the channel URI from the Visual Studio Output Window and paste it in the ASP.NET test application. After this step, you can send tile updates to EvenTiles.</p>
<p>&#160;</p>
<p><a href="http://mstruys.files.wordpress.com/2012/04/image4.png"><img style="background-image:none;margin:5px 0;padding-left:0;padding-right:0;display:inline;float:right;padding-top:0;border-width:0;" title="image" border="0" alt="image" align="right" src="http://mstruys.files.wordpress.com/2012/04/image_thumb4.png?w=240&#038;h=100" width="240" height="100" /></a>The ASP.NET test application does so in a <a href="http://msdn.microsoft.com/en-us/library/System.Threading.ThreadPool.aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">ThreadPool</a> thread. You can specify the number of updates and the time between updates. Each time another update is send, the count property that will be displayed on the front side of the Secondary Tile that EvenTiles pinned on the start screen will be updated.</p>
<p>Even though Background Agents are not supported on 256-MB devices, we have a nice workaround by making use of Push Notifications because they are fully supported. Of course this means that you need to invest more in server side programming, but it also means that the end user experience of a Windows Phone application can be very similar on both a 512-MB device and a 256-MB device. For this to work, the target device must have a network connection.</p>
<p>The complete sample code for EvenTiles so far can be <a title="EvenTiles and Push Notifications Sample Code" href="https://skydrive.live.com/redir.aspx?cid=3302ab496146f161&amp;resid=3302AB496146F161!5996&amp;parid=3302AB496146F161!5870&amp;authkey=!AE25PAA8la1Aw-s" target="_blank">downloaded here</a>. If you want to test the application on a 256-MB device (emulator), you will need to download and install the <a href="http://www.microsoft.com/download/en/details.aspx?id=29233" target="_blank">Windows Phone 7.1.1 SDK Update</a> as well. The ASP.NET test application is also available as a <a title="EvenTiles Web Application to test Push Notifications" href="https://skydrive.live.com/redir.aspx?cid=3302ab496146f161&amp;resid=3302AB496146F161!5995&amp;parid=3302AB496146F161!5870&amp;authkey=!AJscKfTgqkOXY2Y" target="_blank">separate download</a>. In order to run this test application, you need a version of Visual Studio 2010 that supports creating&#160; and debugging ASP.NET applications.</p>
<p>The following video shows how to subscribe to Tile Notifications from within the EvenTiles application and how to test the newly added functionality by means of an APS.NET test application.</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:07bc09fa-863d-49f6-bcf3-2cfa400d0aed" class="wlWriterEditableSmartContent">
<div><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='448' height='252' src='http://www.youtube.com/embed/ucZS7eyp24M?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;hd=1&#038;wmode=transparent' frameborder='0'></iframe></span></div>
<div style="width:448px;clear:both;font-size:.8em;">Using Push Notifications to update Live Tiles on Windows Phone</div>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mstruys.wordpress.com/374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mstruys.wordpress.com/374/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=374&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mstruys.com/2012/04/25/eventiles-and-push-notifications/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef2225df699c5c8ad7ed7c0287d87b41?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mstruys</media:title>
		</media:content>

		<media:content url="http://mstruys.files.wordpress.com/2012/04/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://mstruys.files.wordpress.com/2012/04/image_thumb4.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>EvenTiles and 256-MB Windows Phone Devices</title>
		<link>http://mstruys.com/2012/04/19/eventiles-and-256-mb-windows-phone-devices/</link>
		<comments>http://mstruys.com/2012/04/19/eventiles-and-256-mb-windows-phone-devices/#comments</comments>
		<pubDate>Thu, 19 Apr 2012 18:13:26 +0000</pubDate>
		<dc:creator>Maarten Struys</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[Windows Phone SDK 7.1.1 Update]]></category>
		<category><![CDATA[256-MB Windows Phone Devices]]></category>
		<category><![CDATA[DeviceExtendedProperties]]></category>

		<guid isPermaLink="false">https://mstruys.wordpress.com/?p=367</guid>
		<description><![CDATA[In part 18 of the continuing story of EvenTiles we will take a look at targeting additional Windows Phone devices that will shortly hit the market in several countries. A few weeks ago, the Windows Phone 7.1.1 SDK Update became available for download. This SDK contains everything you need to develop Windows Phone applications that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=367&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In part 18 of the continuing story of EvenTiles we will take a look at targeting additional Windows Phone devices that will shortly hit the market in several countries. A few weeks ago, the <a href="http://www.microsoft.com/download/en/details.aspx?id=29233" target="_blank">Windows Phone 7.1.1 SDK Update</a> became available for download. This SDK contains everything you need to develop Windows Phone applications that target the new <a href="http://msdn.microsoft.com/en-us/library/hh855081(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">256-MB devices</a>. Compared to Windows Phone 7.5 devices, these devices have less memory available, but they can run almost all applications that will run on Windows Phone 7.5 devices as long as they don’t use excessive amounts of memory and as long as they don’t make use of generic background services.</p>
<p>Even though the latter is no problem for most applications (especially since users might have disabled background processing for a particular application on Windows Phone 7.5 devices), in the case of EvenTiles this is kind of an interesting limitation. After all, EvenTiles was originally created to show you how to develop Windows Phone applications, but background processing became one of the more important features of the application. Having said that, EvenTiles will definitely run on 256-MB Windows Phone devices. The only exception is the fact that the background of the Secondary Tile that can be pinned to the Start Screen will only contain one single string.</p>
<p>Let’s just take a look at how to detect if a Windows Phone application is running on a 256-MB device and how we can limit functionality in that particular case. Since background processing is unavailable on a <a href="http://mstruys.files.wordpress.com/2012/04/image1.png"><img style="background-image:none;margin:5px 5px 5px 0;padding-left:0;padding-right:0;display:inline;float:left;padding-top:0;border-width:0;" title="image" border="0" alt="image" align="left" src="http://mstruys.files.wordpress.com/2012/04/image_thumb1.png?w=240&#038;h=148" width="240" height="148" /></a>256-MB device, it makes a lot of sense to remove the functionality to start and re-schedule a <a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.scheduler.periodictask(v=VS.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">PeriodicTask</a> when EvenTiles runs on such a device. The code to start / stop a PeriodicTask in EvenTiles can be found in the MainPage class in two separate methods (StartPeriodicAgent and RemovePeriodicAgent). This code is also used in the MainPage constructor to optionally renew the PeriodicTask when the Even Tiles application is started.</p>
<p>After installing the Windows Phone 7.1.1 SDK Update, you will not only get a new emulator that allows you to test your application on a 256-MB target, but you will also have the ability to check the amount of memory that your target device can use to distinguish between 256-MB and 512-MB Windows Phone devices. To do so, you will have to inspect the value of a property inside the <a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.info.deviceextendedproperties(v=VS.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">DeviceExtendedProperties</a>. This value can be retrieved through the <strong>ApplicationWorkingSetLimit </strong>property, which returns a long integer. The interesting thing about this property is that it may or may not exist on particular Windows Phone devices. If the property exists, it will give back a value representing the current application&#8217;s memory working set limit on a device. If this value contains the equivalent of 90 MB, the application is running on a 256-MB Windows Phone device, otherwise it is running on a 512-MB device. However, if the application is running on a device that does not contain the latest Windows Phone operating system update, the ApplicationWorkingSetLimit property will not be defined and an exception will be thrown when trying to retrieve the value of that property. In this case, the exception can be treated as ‘expected’ behavior for 512-MB devices. This means we can detect the device we are running on by making use of the following code snippet:</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:92c5e917-7280-4d6b-81ab-0a38a1a33995" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Running on a 256-MB Device?</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">const</span> <span style="color:#0000ff;">string</span> keyIsLowMemDevice = <span style="color:#a31515;">&quot;K_256MB&quot;</span>;</li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">bool</span> IsLowMemDevice { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">set</span>; }</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">private</span> <span style="color:#2b91af;">IsolatedStorageSettings</span> appSettings = <span style="color:#2b91af;">IsolatedStorageSettings</span>.ApplicationSettings;</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;"><span style="color:#008000;">// Code to execute when the application is launching (eg, from Start)</span></li>
<li><span style="color:#008000;">// This code will not execute when the application is reactivated</span></li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> Application_Launching(<span style="color:#0000ff;">object</span> sender, <span style="color:#2b91af;">LaunchingEventArgs</span> e)</li>
<li>{</li>
<li style="background:#f3f3f3;">    <span style="color:#0000ff;">if</span> (!appSettings.Contains(keyIsLowMemDevice))</li>
<li>    {</li>
<li style="background:#f3f3f3;">        <span style="color:#0000ff;">try</span></li>
<li>        {</li>
<li style="background:#f3f3f3;">            <span style="color:#2b91af;">Int64</span> result = (<span style="color:#2b91af;">Int64</span>)<span style="color:#2b91af;">DeviceExtendedProperties</span>.GetValue(<span style="color:#a31515;">&quot;ApplicationWorkingSetLimit&quot;</span>);</li>
<li>            <span style="color:#0000ff;">if</span> (result &lt; (<span style="color:#0000ff;">long</span>)(90 * 1024 * 1024))</li>
<li style="background:#f3f3f3;">                IsLowMemDevice = <span style="color:#0000ff;">true</span>;</li>
<li>            <span style="color:#0000ff;">else</span></li>
<li style="background:#f3f3f3;">                IsLowMemDevice = <span style="color:#0000ff;">false</span>;</li>
<li>        }</li>
<li style="background:#f3f3f3;">        <span style="color:#0000ff;">catch</span> (<span style="color:#2b91af;">ArgumentOutOfRangeException</span>)</li>
<li>        {</li>
<li style="background:#f3f3f3;">            <span style="color:#008000;">// Windows Phone OS update not installed, which indicates a 512-MB device. </span></li>
<li>            IsLowMemDevice = <span style="color:#0000ff;">false</span>;</li>
<li style="background:#f3f3f3;">        }</li>
<li>        appSettings[keyIsLowMemDevice] = IsLowMemDevice;</li>
<li style="background:#f3f3f3;">    }</li>
<li>    <span style="color:#0000ff;">else</span></li>
<li style="background:#f3f3f3;">    {</li>
<li>        IsLowMemDevice = (<span style="color:#0000ff;">bool</span>)appSettings[keyIsLowMemDevice];</li>
<li style="background:#f3f3f3;">    }</li>
<li>}</li>
</ol></div>
</p></div>
</p></div>
<p>In this code snippet, we store a boolean value in the application settings to indicate if we are running on a low memory device. To determine the device on which the application is running, we inspect the DeviceExtendedProperties once. The reason to do this only once is to not continuously run into exceptions, which would in fact hurt performance during application initialization on a device that does not have the latest operating system update. Once we know on which device we are running, we can now either enable or disable background processing as is shown in the next code snippet that takes care of pinning / removing a Secondary Tile as a result of clicking the install button:</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f243a7f8-0389-4e05-baa5-79cb34078904" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">No Background Agent on 256-MB</div>
<div style="background:#ddd;max-height:300px;overflow:auto;">
<ol start="1" style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> btnInstall_Click(<span style="color:#0000ff;">object</span> sender, <span style="color:#2b91af;">RoutedEventArgs</span> e)</li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#0000ff;">if</span> (secondaryTileInstalled)</li>
<li style="background:#f3f3f3;">    {</li>
<li>        <span style="color:#0000ff;">var</span> secondaryTile = <span style="color:#2b91af;">ShellTile</span>.ActiveTiles.FirstOrDefault(x =&gt; x.NavigationUri.ToString().Contains(<span style="color:#a31515;">&quot;TileId=Secondary&quot;</span>));</li>
<li style="background:#f3f3f3;">        <span style="color:#0000ff;">if</span> (secondaryTile != <span style="color:#0000ff;">null</span>)</li>
<li>        {</li>
<li style="background:#f3f3f3;">            <span style="color:#0000ff;">if</span> (!<span style="color:#2b91af;">App</span>.IsLowMemDevice)</li>
<li>            {</li>
<li style="background:#f3f3f3;">                RemovePeriodicAgent();</li>
<li>            }</li>
<li style="background:#f3f3f3;">            secondaryTile.Delete();</li>
<li>            btnInstall.Content = txtInstallTile;</li>
<li style="background:#f3f3f3;">            secondaryTileInstalled = <span style="color:#0000ff;">false</span>;</li>
<li>        }</li>
<li style="background:#f3f3f3;">    }</li>
<li>    <span style="color:#0000ff;">else</span></li>
<li style="background:#f3f3f3;">    {</li>
<li>        <span style="color:#0000ff;">if</span> (!<span style="color:#2b91af;">App</span>.IsLowMemDevice)</li>
<li style="background:#f3f3f3;">        {</li>
<li>            StartPeriodicAgent();</li>
<li style="background:#f3f3f3;">        }</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;">        <span style="color:#2b91af;">StandardTileData</span> NewTileData = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">StandardTileData</span></li>
<li>        {</li>
<li style="background:#f3f3f3;">            BackgroundImage = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">Uri</span>(<span style="color:#a31515;">&quot;Background.png&quot;</span>, <span style="color:#2b91af;">UriKind</span>.Relative),</li>
<li>            Title = <span style="color:#a31515;">&quot;EvenTiles&quot;</span>,</li>
<li style="background:#f3f3f3;">            Count = 0,</li>
<li>            BackBackgroundImage = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">Uri</span>(<span style="color:#a31515;">&quot;BackBackTile.png&quot;</span>, <span style="color:#2b91af;">UriKind</span>.Relative),</li>
<li style="background:#f3f3f3;">            BackTitle = <span style="color:#a31515;">&quot;EvenTiles&quot;</span>,</li>
<li>            BackContent = <span style="color:#2b91af;">App</span>.ActualSecBackContent</li>
<li style="background:#f3f3f3;">        };</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;">        <span style="color:#2b91af;">ShellTile</span>.Create(<span style="color:#0000ff;">new</span> <span style="color:#2b91af;">Uri</span>(<span style="color:#a31515;">&quot;/MainPage.xaml?TileId=Secondary&quot;</span>, <span style="color:#2b91af;">UriKind</span>.Relative), NewTileData);</li>
<li>    }</li>
<li style="background:#f3f3f3;">}</li>
</ol></div>
</p></div>
</p></div>
<p>From a functional point of view, it now makes perfect sense to run EvenTiles on 256-BM devices as well. However, we can take it one step further if you want to have different data on the back side of a Secondary Tile. Since <a href="http://msdn.microsoft.com/en-us/library/ff402537(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">Push Notifications</a> are fully supported on 256-MB Windows Phone devices, you can use those to update the application tile, thus we will extend EvenTiles with Push Notification support.</p>
<p>There are even more optimizations that we can make when EvenTiles is running on a 256-MB device. To transfer data between the application and its PeriodicTask we were using a file, as explained when we discussed <a href="https://mstruys.wordpress.com/2012/01/08/eventiles-from-start-to-finishpart-13/" target="_blank">how data can be exchanged between different processes</a>. This means that we don’t need that file when running on a 256-MB device. This makes running the application on a 256-MB device even more efficient. In case of a 256-MB device, we only store the string that needs to be displayed in the application settings. On all other devices, we also store that string in a file through the TileData helper class so the PeriodicTask can retrieve it, as shown in the following code snippet.</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:961a9da6-fc7a-4c96-9223-983b3815928d" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">No transfer on 256-MB device</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">override</span> <span style="color:#0000ff;">void</span> OnNavigatedFrom(System.Windows.Navigation.<span style="color:#2b91af;">NavigationEventArgs</span> e)</li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#0000ff;">if</span> (!<span style="color:#2b91af;">App</span>.ActualSecBackContent.Equals(tbBackContent.Text))</li>
<li style="background:#f3f3f3;">    {</li>
<li>        <span style="color:#2b91af;">App</span>.ActualSecBackContent = tbBackContent.Text;</li>
<li style="background:#f3f3f3;">        <span style="color:#0000ff;">if</span> (!<span style="color:#2b91af;">App</span>.IsLowMemDevice)</li>
<li>        {</li>
<li style="background:#f3f3f3;">            <span style="color:#2b91af;">TileData</span>.SecondaryBackContent = tbBackContent.Text;</li>
<li>            <span style="color:#2b91af;">TileData</span>.ShowDefaultSecondaryBackContent = <span style="color:#0000ff;">false</span>;</li>
<li style="background:#f3f3f3;">        }</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;">        <span style="color:#0000ff;">var</span> TileToFind = <span style="color:#2b91af;">ShellTile</span>.ActiveTiles.FirstOrDefault(x =&gt; x.NavigationUri.ToString().Contains(<span style="color:#a31515;">&quot;TileId=Secondary&quot;</span>));</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;">        <span style="color:#0000ff;">if</span> (TileToFind != <span style="color:#0000ff;">null</span>)</li>
<li>        {</li>
<li style="background:#f3f3f3;">            <span style="color:#2b91af;">StandardTileData</span> NewTileData = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">StandardTileData</span></li>
<li>            {</li>
<li style="background:#f3f3f3;">                BackContent = tbBackContent.Text</li>
<li>            };</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>            TileToFind.Update(NewTileData);</li>
<li style="background:#f3f3f3;">        }</li>
<li>    }</li>
<li style="background:#f3f3f3;">    <span style="color:#0000ff;">base</span>.OnNavigatedFrom(e);</li>
<li>}</li>
</ol></div>
</p></div>
</p></div>
<p><a href="http://mstruys.files.wordpress.com/2012/04/image2.png"><img style="background-image:none;margin:5px 5px 5px 0;padding-left:0;padding-right:0;display:inline;float:left;padding-top:0;border-width:0;" title="image" border="0" alt="image" align="left" src="http://mstruys.files.wordpress.com/2012/04/image_thumb2.png?w=240&#038;h=100" width="240" height="100" /></a>If you are running EvenTiles on either a 256-MB Device or a 512-MB Device you don’t really experience any difference in performance. The application runs well, and it does not start noticeably slower on a 256-MB Device. Of course, EvenTiles uses only a limited amount of memory. The only difference you will notice is that the backside of the Secondary Tile will not display alternating texts. The reason is the absence of Background Agents on 256-MB devices, as you can see in the different screen dumps of both a 256-MB and a 512-MB emulator.</p>
<p>The complete sample code for EvenTiles so far can be <a href="https://skydrive.live.com/redir.aspx?cid=3302ab496146f161&amp;resid=3302AB496146F161!5978&amp;parid=3302AB496146F161!5870&amp;authkey=!AGYxJz9MXzlabbA" target="_blank">downloaded here</a>. If you want to test the application on a 256-MB device (emulator), you will need to download and install the Windows Phone 7.1.1 SDK Update as well. After installing this update, you can even run your application simultaneously on a 512-MB and a 256-MB emulator and compare the behavior on both of them.</p>
<p><a href="http://mstruys.files.wordpress.com/2012/04/multipleemulators.jpg"><img style="background-image:none;margin:5px 0;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="MultipleEmulators" border="0" alt="MultipleEmulators" src="http://mstruys.files.wordpress.com/2012/04/multipleemulators_thumb.jpg?w=529&#038;h=145" width="529" height="145" /></a></p>
<p>The following video shows how to detect if your application is running on a 256-MB device and it shows how to limit functionality in that case.</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:6f5af6a6-c128-4100-bbf1-51e61da5f312" class="wlWriterEditableSmartContent">
<div><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='448' height='252' src='http://www.youtube.com/embed/tE-t3hNG_dM?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;hd=1&#038;wmode=transparent' frameborder='0'></iframe></span></div>
<div style="width:448px;clear:both;font-size:.8em;">Limiting functionality when running on 256-MB Windows Phone Devices</div>
</div>
<p>In the next episode of EvenTiles we will start talking about Push Notifications.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mstruys.wordpress.com/367/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mstruys.wordpress.com/367/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=367&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mstruys.com/2012/04/19/eventiles-and-256-mb-windows-phone-devices/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef2225df699c5c8ad7ed7c0287d87b41?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mstruys</media:title>
		</media:content>

		<media:content url="http://mstruys.files.wordpress.com/2012/04/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://mstruys.files.wordpress.com/2012/04/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://mstruys.files.wordpress.com/2012/04/multipleemulators_thumb.jpg" medium="image">
			<media:title type="html">MultipleEmulators</media:title>
		</media:content>
	</item>
		<item>
		<title>EvenTiles and TrialMode</title>
		<link>http://mstruys.com/2012/04/16/eventiles-and-trialmode/</link>
		<comments>http://mstruys.com/2012/04/16/eventiles-and-trialmode/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 17:45:37 +0000</pubDate>
		<dc:creator>Maarten Struys</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[Marketplace]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[Windows Phone SDK 7.1]]></category>
		<category><![CDATA[IsTrial]]></category>
		<category><![CDATA[LicenseInformation]]></category>

		<guid isPermaLink="false">https://mstruys.wordpress.com/?p=356</guid>
		<description><![CDATA[In part 17 of EvenTiles we will take a look at Trial Mode. When an application supports trial mode, users can first try the application before buying it. It is up to you as the application developer to determine which functionality is available in the application when running in trial mode. Even though trial mode [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=356&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In part 17 of EvenTiles we will take a look at <a href="http://msdn.microsoft.com/en-us/library/ff967558(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">Trial Mode</a>. When an application supports trial mode, users can first try the application before buying it. It is up to you as the application developer to determine which functionality is available in the application when running in trial mode. Even though trial mode makes your application slightly more complex, the advantage of implementing trial mode is that you will only have to submit one single version of your application that customers can either try or buy. The application is started with either a trial license or a full license (when the user purchased the application). Inside the application, you can make use of an <a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.marketplace.licenseinformation.istrial(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">API</a> to determine if a user is running your application in trial mode or not. From a technical point of view, there are no restrictions to trial mode, so you can even provide full application functionality in trial mode. Of course that does not make sense, because you typically want to use trial mode to invite end users to try your application after which they hopefully get so excited about your application that they determine to buy it.</p>
<blockquote><p><strong>NOTE:</strong> Be careful with providing a limited time to execute a fully functional application in trial mode, because end users can simply reinstall your application to again run the application for a certain amount of time in trial mode.</p>
</blockquote>
<p>Let’s assume that EvenTile has two different modes of operation, implemented through Trial Mode. In Trial Mode, EvenTiles is fully functional without restrictions, however, the application will display ads on the main page (adding the actual advertisements to EvenTiles will be covered later in this series). As soon as users purchase EvenTiles, advertisements will be disabled. In trial mode, the application also contains functionality to retrieve location information in order to receive localized advertisements, although the user can disable location retrieval through the Settings Page of the application. However, if a user purchases the application, location information will not be retrieved and it does not make sense to have a toggle switch in the Settings Page to enable / disable location retrieval. Finally, if the user runs EvenTiles in trial mode, they have the option to purchase the application from within the application’s About Page. Of course, this option is only available in trial mode, if the application is already purchases, the About Page allows a user to display more applications that were published by DotNETForDevices.</p>
<p>Let’s begin by finding out how we can determine if the application is currently running in Trial Mode. In order to do so, as long as the user is running the application in Trial Mode, we will check the current application’s license each time the application starts or becomes the foreground application, and set a Boolean property accordingly. We also store the current value of that Boolean property in our application settings. When a user has purchased the application, we only have to check the application settings which results in faster starting / resuming of the application. The following code snippet shows how to determine if we are running in Trial mode:</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:377debee-6365-44a0-8ac2-524706f200fd" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Running in Trial Mode?</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">const</span> <span style="color:#0000ff;">string</span> keyTrialMode = <span style="color:#a31515;">&quot;K_TRIAL&quot;</span>;</li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">bool</span> IsTrialMode { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">set</span>; }</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> Application_Launching(<span style="color:#0000ff;">object</span> sender, <span style="color:#2b91af;">LaunchingEventArgs</span> e)</li>
<li>{</li>
<li style="background:#f3f3f3;">    <span style="color:#0000ff;">if</span> (!appSettings.Contains(keyTrialMode))</li>
<li>    {</li>
<li style="background:#f3f3f3;">        appSettings[keyTrialMode] = <span style="color:#0000ff;">true</span>;</li>
<li>    }</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>    IsTrialMode = (<span style="color:#0000ff;">bool</span>)appSettings[keyTrialMode];</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>    <span style="color:#0000ff;">if</span> (IsTrialMode)</li>
<li style="background:#f3f3f3;">    {</li>
<li>        CheckTrialMode();</li>
<li style="background:#f3f3f3;">    }</li>
<li>}</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> CheckTrialMode()</li>
<li style="background:#f3f3f3;">{</li>
<li>    IsTrialMode = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">LicenseInformation</span>().IsTrial();</li>
<li style="background:#f3f3f3;">}</li>
</ol></div>
</p></div>
</p></div>
<p>This snippet only shows checking for Trial Mode when the application is launched. We first determine if we already stored the current license type in our application settings. If we assume we are running in Trial Mode we need to check if the license type has chanced since the last time the user ran the application. Since correct license information will only be added when the application is downloaded from the Windows Phone Marketplace, it might be a little tricky to test this functionality. When you installed the application locally on an unlocked device during testing of your application, or when you execute the application from within Visual Studio, the <a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.marketplace.licenseinformation.istrial(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">LicenseInformation.IsTrial</a> method always returns <strong>false</strong>. With a little bit of conditional compilation, we can easily change this for test purposes. In the following code snippet you can see that we can test Trial mode when we are running the application in Debug mode and when the <strong>TRIAL </strong>symbol is defined. By simply setting this symbol to <strong>NO_TRIAL </strong>we can test the application for both different license types.</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bf6586c4-eb84-41f7-99d4-070aae12e1a0" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Testing Trial Mode</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#0000ff;">#if</span> DEBUG</li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">#define</span> TRIAL</li>
<li><span style="color:#0000ff;">#endif</span></li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li><span style="color:#0000ff;">using</span> System.Windows;</li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">using</span> Microsoft.Phone.Marketplace;</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">namespace</span> EvenTiles</li>
<li>{</li>
<li style="background:#f3f3f3;">    <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">App</span> : <span style="color:#2b91af;">Application</span></li>
<li>    {</li>
<li style="background:#f3f3f3;">        <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> CheckTrialMode()</li>
<li>        {</li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">#if</span> ! TRIAL</li>
<li>            <span style="color:#808080;">IsTrialMode = new LicenseInformation().IsTrial();</span></li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">#endif</span></li>
<li>        }</li>
</ol></div>
</p></div>
</p></div>
<p>In the <strong>OnLaunching </strong>method of the application, the <strong>IsTrialMode </strong>property is initialized to <strong>true </strong>and optionally modified by executing the <strong>CheckTrialMode </strong>method. If you want to test the application as if it was purchased by a user, you can simply change <strong>TRIAL</strong> to <strong>NO_TRIAL</strong>, recompile and execute the application again.</p>
<blockquote><p><strong>NOTE:</strong> If you take this approach, make sure that you install a clean copy of the application to a device or the emulator when switching back to trial mode. The way the code is organized, once the <strong>IsTrialMode</strong> property is set to false, the call to the <strong>LicenseInformation.IsTrial</strong> method is never executed again. To install a clean copy, make sure to rebuild your application in Visual Studio before deploying it, instead of simply building the application. After a rebuild, not only the application is replaced on the target device, but the entire IsolatedStorage area of the application is cleaned.</p>
</blockquote>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a2d9c41c-cbcb-4104-a6b0-32323f8e49e8" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Testing a purchased app</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#0000ff;">#if</span> DEBUG</li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">#define</span> NO_TRIAL</li>
<li><span style="color:#0000ff;">#endif</span></li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li><span style="color:#0000ff;">using</span> System.Windows;</li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">using</span> Microsoft.Phone.Marketplace;</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">namespace</span> EvenTiles</li>
<li>{</li>
<li style="background:#f3f3f3;">    <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">App</span> : <span style="color:#2b91af;">Application</span></li>
<li>    {</li>
<li style="background:#f3f3f3;">        <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> CheckTrialMode()</li>
<li>        {</li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">#if</span> ! TRIAL</li>
<li>            IsTrialMode = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">LicenseInformation</span>().IsTrial();</li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">#endif</span></li>
<li>        }</li>
</ol></div>
</p></div>
</p></div>
<p>Since Debug is not set in release mode, you will always call the <strong>LicenseInformation.IsTrial</strong> method when the application is deployed to a device.</p>
<p>Since we now have determined if the application is running in Trial Mode or not, we can simply use this information to display / hide the location retrieval toggle button on the Settings Page. Also, when can alter the functionality of one of the buttons on the About Page. If the application runs in Trial Mode, the user can purchase the application from within the About Page. If the user already has purchased the application, they can use the same button to check more applications from the same publisher, as shown in the following code snippet:</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9edce7cd-d49e-4221-944d-654dd18fe88c" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Changing button behavior</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">AboutPage</span> : <span style="color:#2b91af;">PhoneApplicationPage</span></li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#0000ff;">public</span> AboutPage()</li>
<li style="background:#f3f3f3;">    {</li>
<li>        InitializeComponent();</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>        btnMore.Content = <span style="color:#2b91af;">App</span>.IsTrialMode ? <span style="color:#a31515;">&quot;Purchase EvenTiles now&quot;</span> : <span style="color:#a31515;">&quot;More from DotNETForDevices&quot;</span>;</li>
<li style="background:#f3f3f3;">    }</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;">    <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> btnMore_Click(<span style="color:#0000ff;">object</span> sender, <span style="color:#2b91af;">RoutedEventArgs</span> e)</li>
<li>    {</li>
<li style="background:#f3f3f3;">        <span style="color:#0000ff;">if</span> (<span style="color:#2b91af;">App</span>.IsTrialMode)</li>
<li>        {</li>
<li style="background:#f3f3f3;">            <span style="color:#2b91af;">MarketplaceDetailTask</span> detailTask = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">MarketplaceDetailTask</span>();</li>
<li>            detailTask.Show();</li>
<li style="background:#f3f3f3;">        }</li>
<li>        <span style="color:#0000ff;">else</span></li>
<li style="background:#f3f3f3;">        {</li>
<li>            <span style="color:#0000ff;">var</span> searchTask = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">MarketplaceSearchTask</span></li>
<li style="background:#f3f3f3;">            {</li>
<li>                ContentType = <span style="color:#2b91af;">MarketplaceContentType</span>.Applications,</li>
<li style="background:#f3f3f3;">                SearchTerms = <span style="color:#a31515;">&quot;DotNETForDevices&quot;</span></li>
<li>            };</li>
<li style="background:#f3f3f3;">            searchTask.Show();</li>
<li>        }</li>
<li style="background:#f3f3f3;">    }</li>
<li>}</li>
</ol></div>
</p></div>
</p></div>
<p>When the application is running, it either shows the location toggle switch and it provides different functionality in the About Page.</p>
<p><a href="http://mstruys.files.wordpress.com/2012/04/image.png"><img style="background-image:none;margin:5px 0;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" border="0" alt="image" src="http://mstruys.files.wordpress.com/2012/04/image_thumb.png?w=520&#038;h=210" width="520" height="210" /></a></p>
<p>The following video shows how to add Trial Mode to the EvenTiles application. It also shows how you can test this functionality by making use of some conditional compilation.</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:491bc042-60cf-48f5-98af-364b7d8512b0" class="wlWriterEditableSmartContent">
<div><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='516' height='289' src='http://www.youtube.com/embed/CehtPuhYNmM?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;hd=1&#038;wmode=transparent' frameborder='0'></iframe></span></div>
<div style="width:516px;clear:both;font-size:.8em;">Adding TrialMode to the application and testing TrialMode.</div>
</div>
<p>To be able to experiment with the functionality of EvenTiles as it is right now, the sample code is available for <a href="https://skydrive.live.com/redir.aspx?cid=3302ab496146f161&amp;resid=3302AB496146F161!5976&amp;parid=3302AB496146F161!5870&amp;authkey=!AAt4T7duP5BkSCU" target="_blank">dowload here</a>. In the next episode of EvenTiles we will talk about adding support to run EvenTiles on <a href="http://msdn.microsoft.com/en-us/library/hh855081(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">256-MB Windows Phone</a> devices.</p>
<p><a href="http://www.windowsphone.com/en-US/apps/27024895-5091-4ebb-8f2a-89e34cd9f9ee"><img style="margin:0 5px 5px 0;" border="0" alt="EvenTiles" align="left" src="http://catalog.zune.net/v3.2/en-US/apps/27024895-5091-4ebb-8f2a-89e34cd9f9ee/primaryImage?width=95&amp;height=95&amp;resize=true" /></a>You can already install the latest version of EvenTile on your own Windows Phone. from Marketplace. Remember that the application is not meant to be extremely useful, although it contains similar functionality that “serious” applications have. Just go ahead and get here: <a href="http://www.windowsphone.com/en-US/search?q=EvenTiles">http://www.windowsphone.com/en-US/search?q=EvenTiles</a> (or search on your phone for EvenTiles in the Marketplace application).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mstruys.wordpress.com/356/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mstruys.wordpress.com/356/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=356&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mstruys.com/2012/04/16/eventiles-and-trialmode/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef2225df699c5c8ad7ed7c0287d87b41?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mstruys</media:title>
		</media:content>

		<media:content url="http://mstruys.files.wordpress.com/2012/04/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://catalog.zune.net/v3.2/en-US/apps/27024895-5091-4ebb-8f2a-89e34cd9f9ee/primaryImage?width=95&#38;height=95&#38;resize=true" medium="image">
			<media:title type="html">EvenTiles</media:title>
		</media:content>
	</item>
		<item>
		<title>EvenTiles will continue in a few weeks</title>
		<link>http://mstruys.com/2012/02/15/eventiles-will-continue-in-a-few-weeks/</link>
		<comments>http://mstruys.com/2012/02/15/eventiles-will-continue-in-a-few-weeks/#comments</comments>
		<pubDate>Wed, 15 Feb 2012 22:43:24 +0000</pubDate>
		<dc:creator>Maarten Struys</dc:creator>
				<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">https://mstruys.wordpress.com/?p=351</guid>
		<description><![CDATA[During the upcoming weeks I am on the road, making it impossible to add more content to the EvenTiles Windows Phone application development series. Nothing to worry though. Be ready for lots of additional content in a few weeks, including source code and videos. When the series continues, we will cover Trial Mode, the Ad [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=351&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>During the upcoming weeks I am on the road, making it impossible to add more content to the EvenTiles Windows Phone application development series. Nothing to worry though. Be ready for lots of additional content in a few weeks, including source code and videos. When the series continues, we will cover Trial Mode, the Ad Control, Performance optimization, using the camera and much more. When all functionality is in place we will also talk about alternative application architectures. Simply stay tuned.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mstruys.wordpress.com/351/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mstruys.wordpress.com/351/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=351&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mstruys.com/2012/02/15/eventiles-will-continue-in-a-few-weeks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef2225df699c5c8ad7ed7c0287d87b41?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mstruys</media:title>
		</media:content>
	</item>
		<item>
		<title>EvenTiles from Start to Finish&#8211;Part 16</title>
		<link>http://mstruys.com/2012/02/01/eventiles-from-start-to-finishpart-16/</link>
		<comments>http://mstruys.com/2012/02/01/eventiles-from-start-to-finishpart-16/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 15:00:53 +0000</pubDate>
		<dc:creator>Maarten Struys</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[Marketplace]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Windows Phone 7]]></category>
		<category><![CDATA[Windows Phone SDK 7.1]]></category>
		<category><![CDATA[EmailComposeTask]]></category>
		<category><![CDATA[MarketplaceReviewTask]]></category>
		<category><![CDATA[MarketplaceSearchTask]]></category>

		<guid isPermaLink="false">https://mstruys.wordpress.com/?p=349</guid>
		<description><![CDATA[In the previous episode of this series about how to develop a Windows Phone application from scratch you learned how to create the UI of a more or less typical About Page using Expression Blend. The About Page contains nothing fancy, just a number of TextBlocks and a few Buttons. Right now we are ready [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=349&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In the <a href="https://mstruys.wordpress.com/2012/01/26/eventiles-from-start-to-finishpart-15/" target="_blank">previous episode</a> of this series about how to develop a Windows Phone application from scratch you learned how to create the UI of a more or less typical About Page using Expression Blend. The About Page contains nothing fancy, just a number of TextBlocks and a few Buttons. Right now we are ready to add some functionality to the About Page to</p>
<ul>
<li>Display the application’s version in a TextBlock </li>
<li>Submit an email containing remarks and/or suggestions to the application’s publisher </li>
<li>Submit a review for the application </li>
<li>Check Marketplace for more applications, available from the same publisher </li>
</ul>
<p><a href="http://mstruys.files.wordpress.com/2012/02/screen1.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;float:left;padding-top:0;border-width:0;margin:5px 5px 5px 0;" title="screen1" border="0" alt="screen1" align="left" src="http://mstruys.files.wordpress.com/2012/02/screen1_thumb.png?w=144&#038;h=240" width="144" height="240" /></a></p>
<p>In itself, these are all small, relatively easy and partly unrelated actions. However, the latter 3 items, even though different, all have something in common. In order to achieve the desired result, we will make use of functionality that is available in a Windows Phone, but outside of our application. To use that specific functionality, we will make use of different Windows Phone <a href="http://msdn.microsoft.com/en-us/library/ff769550(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">Launchers</a>. You can think of a Launcher as a separate application that can be shared by our applications to allow users to perform some common tasks in a uniform and consistent way. The fact that a Launcher starts a separate, built-in application, has some consequences for our application that makes use of the Launcher. When the application we launched becomes active, our application will be moved to the background. This means that our application will temporarily be paused and even be <a href="http://msdn.microsoft.com/en-us/library/ff817008(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">tombstoned</a> in low memory / resource situations. Since we already took care of properly dealing with our application being moved to the background (<a href="https://mstruys.wordpress.com/2011/12/12/eventiles-from-start-to-finishpart-7/" target="_blank">see episode 7 about Tombstoning</a>), this is not a big deal but it is good to realize what is happening under the covers of the Windows Phone platform.</p>
<blockquote><p>Note: Usually Launchers are mentioned together with <a href="http://msdn.microsoft.com/en-us/library/ff769543(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">Choosers</a> because they provide similar functionality and operate more or less the same. The big difference between them is that a Chooser (as the word implies) is capable of selecting some data (for instance a picture) and return the selected item to our application. Choosers will be covered in a later episode of EvenTiles.</p>
</blockquote>
<p>As always, it makes a lot of sense to see things in action and to take a look at actual code. That is the reason why, besides these series of blog entries, there are also accompanying videos and sample code available for download.</p>
<h4>Retrieving the application’s version number</h4>
<p>The first goal we want to achieve is to retrieve the <a href="http://msdn.microsoft.com/en-us/library/gg442301(v=VS.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">version number</a> of our application and display it in the About page. Since our application stores its own version number in its <a href="http://msdn.microsoft.com/en-us/library/ff769509(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">manifest file</a>, we want to retrieve it from there.</p>
<blockquote><p>NOTE: The version number must also be specified when submitting an application to the Windows Phone Marketplace. According to the documentation, this version number must match your application’s version number but maintaining it in your manifest file is a separate activity. There is yet another version number, stored in the application’s AssemblyInfo.cs file and modifiable through the project properties. In EvenTiles we ignore the latter and retrieve the version number immediately from the application’s manifest file. </p>
</blockquote>
<p>Application version numbers consist of major, minor, build, and revision components. To match the version number as it is showed in the Windows Phone Marketplace, we only want to display the major and minor parts of the application. Since the application manifest file is just another XML file, we can easily retrieve the version number from it.</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:71f588a9-9ad7-484d-936a-0ac72d56fd25" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Version info in manifest file</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;white-space:nowrap;margin:0;padding:0 0 0 5px;">
<li><span style="color:#0000ff;">&lt;</span><span style="color:#a31515;">App</span><span style="color:#0000ff;"> </span><span style="color:#ff0000;">xmlns</span><span style="color:#0000ff;">=</span>&quot;&quot;<span style="color:#0000ff;"> </span></li>
<li style="background:#f3f3f3;">     <span style="color:#0000ff;"></span><span style="color:#ff0000;">ProductID</span><span style="color:#0000ff;">=</span>&quot;{<span style="color:#0000ff;">883385e6-52e5-4835-83db-8a17499b5767}</span>&quot;<span style="color:#0000ff;"> </span></li>
<li>     <span style="color:#0000ff;"></span><span style="color:#ff0000;">Title</span><span style="color:#0000ff;">=</span>&quot;<span style="color:#0000ff;">EvenTiles</span>&quot;<span style="color:#0000ff;"> </span></li>
<li style="background:#f3f3f3;">     <span style="color:#0000ff;"></span><span style="color:#ff0000;">RuntimeType</span><span style="color:#0000ff;">=</span>&quot;<span style="color:#0000ff;">Silverlight</span>&quot;<span style="color:#0000ff;"> </span></li>
<li>     <span style="color:#0000ff;"></span><span style="color:#ff0000;">Version</span><span style="color:#0000ff;">=</span>&quot;<span style="color:#0000ff;">1.0.0.0</span>&quot;<span style="color:#0000ff;"> </span></li>
<li style="background:#f3f3f3;">     <span style="color:#0000ff;"></span><span style="color:#ff0000;">Genre</span><span style="color:#0000ff;">=</span>&quot;<span style="color:#0000ff;">apps.normal</span>&quot;<span style="color:#0000ff;"> </span></li>
<li>     <span style="color:#0000ff;"></span><span style="color:#ff0000;">Author</span><span style="color:#0000ff;">=</span>&quot;<span style="color:#0000ff;">Maarten Struys</span>&quot;<span style="color:#0000ff;"> </span></li>
<li style="background:#f3f3f3;">     <span style="color:#0000ff;"></span><span style="color:#ff0000;">Description</span><span style="color:#0000ff;">=</span>&quot;<span style="color:#0000ff;">Sample description</span>&quot;<span style="color:#0000ff;"> </span></li>
<li>     <span style="color:#0000ff;"></span><span style="color:#ff0000;">Publisher</span><span style="color:#0000ff;">=</span>&quot;<span style="color:#0000ff;">DotNETForDevices</span>&quot;<span style="color:#0000ff;">&gt;</span></li>
</ol></div>
</p></div>
</p></div>
<p>To retrieve the version number and to display it in a Textblock inside the About Page, we can just load the XML from the manifest file and find the value of the <strong>version</strong> attribute of the <strong>App </strong>element. The reason why this works is because the application manifest file (WMAppManifest.xml) is deployed to the phone as part of the XAP file.</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7d217848-b4eb-4344-8694-ba7300add43c" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Get version from manifest file</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;white-space:nowrap;margin:0;padding:0 0 0 5px;">
<li><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">string</span> GetVersionNumber()</li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#0000ff;">string</span>[] version = <span style="color:#2b91af;">XDocument</span>.Load(<span style="color:#a31515;">&quot;WMAppManifest.xml&quot;</span>).Root.Element(<span style="color:#a31515;">&quot;App&quot;</span>).Attribute(<span style="color:#a31515;">&quot;Version&quot;</span>).Value.Split(<span style="color:#a31515;">&#039;.&#039;</span>);</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>    <span style="color:#2b91af;">StringBuilder</span> sb = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">StringBuilder</span>(version[0]);</li>
<li style="background:#f3f3f3;">    sb.Append(<span style="color:#a31515;">&quot;.&quot;</span>);</li>
<li>    sb.Append(version[1]);</li>
<li style="background:#f3f3f3;">    versionNumber = sb.ToString();</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;">    <span style="color:#0000ff;">return</span> versionNumber;</li>
<li>}</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> PhoneApplicationPage_Loaded(<span style="color:#0000ff;">object</span> sender, <span style="color:#2b91af;">RoutedEventArgs</span> e)</li>
<li style="background:#f3f3f3;">{</li>
<li>    tbVersion.Text = GetVersionNumber();</li>
<li style="background:#f3f3f3;">}</li>
</ol></div>
</p></div>
</p></div>
<h4>Sending an email</h4>
<p>A nice feature inside a Windows Phone application is the possibility for end users to get in touch with you through email. Making this as easy as possible for end users might result in you getting some useful feedback about your application and might also increase the user’s satisfaction with your application, which in turn might lead to better and more reviews. To send an email programmatically to a fixed email address is very simple. You simply can make use of the <a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.emailcomposetask(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">EmailComposeTask</a> and even pre-populate information in the email to make it easier for the end user to send out an email. The following code shows how to send an email programmatically:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7566677e-554b-44e6-a881-4051cc5623df" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Using the EmailComposeTask</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;white-space:nowrap;margin:0;padding:0 0 0 5px;">
<li><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> btnEmail_Click(<span style="color:#0000ff;">object</span> sender, <span style="color:#2b91af;">RoutedEventArgs</span> e)</li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#2b91af;">StringBuilder</span> sb = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">StringBuilder</span>(<span style="color:#a31515;">&quot;Feedback / Support for EvenTiles &quot;</span>);</li>
<li style="background:#f3f3f3;">    sb.Append(versionNumber);</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;">    <span style="color:#0000ff;">var</span> emailComposeTask = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">EmailComposeTask</span></li>
<li>    {</li>
<li style="background:#f3f3f3;">        To = <span style="color:#a31515;">&quot;mstruys@hotmail.com&quot;</span>,</li>
<li>        Subject = sb.ToString()</li>
<li style="background:#f3f3f3;">    };</li>
<li>    emailComposeTask.Show();</li>
<li style="background:#f3f3f3;">}</li>
</ol></div>
</p></div>
</p></div>
<blockquote><p>NOTE: In order to test this functionality, you have to use a physical device. The Windows Phone Emulator will throw an exception when using the email compose task.</p>
</blockquote>
<h4>Submitting a review</h4>
<p>If you know how to use one Windows Phone Launcher you basically know how to use them all. Since we already saw that sending an email is a very simple operation (creating a new object, setting some properties and calling the Show method on the object), submitting a review should not be difficult. The following code shows how to allow your users to submit a review by using the <a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.marketplacereviewtask(v=VS.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">MarketplaceReviewTask</a> Launcher:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:84e9ad6c-2f12-4916-ba36-b742a7bb0729" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Submitting a review</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;white-space:nowrap;margin:0;padding:0 0 0 5px;">
<li><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> btnReview_Click(<span style="color:#0000ff;">object</span> sender, <span style="color:#2b91af;">RoutedEventArgs</span> e)</li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#2b91af;">MarketplaceReviewTask</span> reviewTask = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">MarketplaceReviewTask</span>();</li>
<li style="background:#f3f3f3;">    reviewTask.Show();</li>
<li>}</li>
</ol></div>
</p></div>
</p></div>
<p><a href="http://mstruys.files.wordpress.com/2012/02/screen2.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;float:left;padding-top:0;border-width:0;margin:0 5px 5px 0;" title="screen2" border="0" alt="screen2" align="left" src="http://mstruys.files.wordpress.com/2012/02/screen2_thumb.png?w=144&#038;h=240" width="144" height="240" /></a></p>
<p>Of course, this code can be extended, for instance by storing in the application settings if a review has already been submitted. If so, we can for instance remove the button to submit a review from the application. We can also verify if we currently have a data connection in order to submit a review. All this functionality is omitted in this sample code.</p>
<h4>Checking for more applications</h4>
<p>Using the same approach as described before, we can also allow the user to look for more applications that we already published on the Windows Phone Marketplace. This can be achieved by using the <a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.marketplacesearchtask(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">MarketplaceSearchTask</a>, again in a similar way:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f4c7a2ea-29da-4081-815d-194cc9010b79" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Finding apps on Marketplace</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;white-space:nowrap;margin:0;padding:0 0 0 5px;">
<li><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> btnMore_Click(<span style="color:#0000ff;">object</span> sender, <span style="color:#2b91af;">RoutedEventArgs</span> e)</li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#0000ff;">var</span> searchTask = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">MarketplaceSearchTask</span></li>
<li style="background:#f3f3f3;">    {</li>
<li>        ContentType = <span style="color:#2b91af;">MarketplaceContentType</span>.Applications,</li>
<li style="background:#f3f3f3;">        SearchTerms = <span style="color:#a31515;">&quot;DotNETForDevices&quot;</span></li>
<li>    };</li>
<li style="background:#f3f3f3;">    searchTask.Show();</li>
<li>}</li>
</ol></div>
</p></div>
</p></div>
<p>The MarketplaceSearchTask is a very nice marketing instrument because you can guide users of your application to other Windows Phone applications you have published.</p>
<p>The following video shows how to create the functionality we described in this episode of EvenTiles. It also shows two of the described Launchers in action, one running in the emulator, one on a physical device.</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:c5d20d77-6481-404b-836b-29c3d5b89095" class="wlWriterEditableSmartContent">
<div><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='448' height='252' src='http://www.youtube.com/embed/yuezDgyeNbU?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;hd=1&#038;wmode=transparent' frameborder='0'></iframe></span></div>
<div style="width:448px;clear:both;font-size:.8em;">Using Launchers inside a Windows Phone Application</div>
</div>
<p>To be able to experiment with this working implementation of EvenTiles, especially to understand how the application interacts with the PeriodicTask through a file in IsolatedStorage, the sample code is available for <a href="https://skydrive.live.com/redir.aspx?cid=3302ab496146f161&amp;resid=3302AB496146F161!5897&amp;parid=3302AB496146F161!5870&amp;authkey=!AMq8jl4gdskbn34" target="_blank">dowload here</a>. In the next episode of EvenTiles we will talk about implementing Trial Mode in your application to allow users to try the application before optionally buying it.</p>
<p><a href="http://www.windowsphone.com/en-US/apps/27024895-5091-4ebb-8f2a-89e34cd9f9ee" target="_blank"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;float:left;padding-top:0;border-width:0;margin:8px 5px 5px 0;" border="0" alt="EvenTiles" align="left" src="http://catalog.zune.net/v3.2/en-US/apps/27024895-5091-4ebb-8f2a-89e34cd9f9ee/primaryImage?width=95&amp;height=95&amp;resize=true" /></a>If you want to see EvenTiles already in action on your Windows Phone, you can also install the latest free version from Marketplace. Remember that this application is not meant to be extremely useful, although it contains similar functionality that “serious” applications have. Just go ahead and get your free copy of EvenTiles from Marketplace at this location: <a href="http://www.windowsphone.com/en-US/search?q=EvenTiles" target="_blank">http://www.windowsphone.com/en-US/search?q=EvenTiles</a> (or search on your phone for EvenTiles in the Marketplace application).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mstruys.wordpress.com/349/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mstruys.wordpress.com/349/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=349&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mstruys.com/2012/02/01/eventiles-from-start-to-finishpart-16/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef2225df699c5c8ad7ed7c0287d87b41?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mstruys</media:title>
		</media:content>

		<media:content url="http://mstruys.files.wordpress.com/2012/02/screen1_thumb.png" medium="image">
			<media:title type="html">screen1</media:title>
		</media:content>

		<media:content url="http://mstruys.files.wordpress.com/2012/02/screen2_thumb.png" medium="image">
			<media:title type="html">screen2</media:title>
		</media:content>

		<media:content url="http://catalog.zune.net/v3.2/en-US/apps/27024895-5091-4ebb-8f2a-89e34cd9f9ee/primaryImage?width=95&#38;height=95&#38;resize=true" medium="image">
			<media:title type="html">EvenTiles</media:title>
		</media:content>
	</item>
		<item>
		<title>EvenTiles Until Now (A Windows Phone Development Series)</title>
		<link>http://mstruys.com/2012/01/28/eventiles-until-now-a-windows-phone-development-series/</link>
		<comments>http://mstruys.com/2012/01/28/eventiles-until-now-a-windows-phone-development-series/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 19:57:00 +0000</pubDate>
		<dc:creator>Maarten Struys</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Windows Phone 7]]></category>
		<category><![CDATA[Windows Phone Power Tools]]></category>
		<category><![CDATA[Windows Phone SDK 7.1]]></category>
		<category><![CDATA[EvenTiles]]></category>
		<category><![CDATA[PeriodicTask]]></category>

		<guid isPermaLink="false">https://mstruys.wordpress.com/?p=342</guid>
		<description><![CDATA[Looking at all the different topics that the EvenTiles series covers, I think it makes sense to at least have a table of contents for the series so far. For instance, if you are interested in reading something about tombstoning, it is not necessary to read through the entire series (although of course I invite [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=342&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Looking at all the different topics that the EvenTiles series covers, I think it makes sense to at least have a table of contents for the series so far. For instance, if you are interested in reading something about tombstoning, it is not necessary to read through the entire series (although of course I invite you to do so anyway). At this moment, EvenTiles explains how to use Windows Phone Tiles, including Secondary Tiles. It also show how you can update content on your Tiles locally by using a Background Agent. Also don’t forget that all source code is available and each individual episode of EvenTiles contains a demo on video as well. The latest <a href="https://skydrive.live.com/redir.aspx?cid=3302ab496146f161&amp;resid=3302AB496146F161!5895&amp;parid=3302AB496146F161!5870&amp;authkey=!AN88UJ1LTX8Q4X0" target="_blank">sample source code can be downloaded</a>.</p>
<p>Here is the table of contents for the first 14 parts of EvenTiles:</p>
<table border="1" cellspacing="0" cellpadding="2" width="525">
<tbody>
<tr>
<td valign="top" width="525">
<p><strong><a title="EvenTiles - Episode 1" href="https://mstruys.wordpress.com/2011/11/23/eventiles-from-start-to-finishpart-1/" target="_blank">Introducing the EvenTiles application</a></strong></p>
<ul>
<li>Creating a new project in Visual Studio 2010 Express for Windows Phone </li>
<li>Defining an Application Tile from within the WMAppManifest.xml file </li>
<li>Using the emulator to run the application </li>
</ul>
</td>
</tr>
<tr>
<td valign="top" width="525">
<p><strong><a title="EvenTiles - Episode 2" href="https://mstruys.wordpress.com/2011/11/26/eventiles-from-start-to-finishpart-2/" target="_blank">PageNavigation and ApplicationBar</a></strong></p>
<ul>
<li>Using Expression Blend to create an Application Bar </li>
<li>Navigating to different pages by using the NavigationService </li>
</ul>
</td>
</tr>
<tr>
<td valign="top" width="525">
<p><strong><a title="EvenTiles - Episode 3" href="https://mstruys.wordpress.com/2011/12/01/eventiles-from-start-to-finishpart-3/" target="_blank">Using the Silverlight for Windows Phone Toolkit in your application</a></strong></p>
<ul>
<li>Defining page transitions in XAML and using them in your application </li>
<li>Using styles in XAML </li>
<li>Declaring and using a ToggleSwitch control </li>
</ul>
</td>
</tr>
<tr>
<td valign="top" width="525">
<p><a title="EvenTiles - Episode 4" href="https://mstruys.wordpress.com/2011/12/04/eventiles-from-start-to-finishpart-4/" target="_blank"><strong>Creating the Settings Page</strong></a></p>
<ul>
<li>Designing a Windows Phone page using Expression Blend </li>
<li>Executing code as a result of page navigation (using <font face="Consolas"><strong>OnNavigatingTo</strong></font> and <font face="Consolas"><strong>OnNavigatingFrom</strong></font>) </li>
<li>Using event handlers to execute code on user interaction with UI elements </li>
</ul>
</td>
</tr>
<tr>
<td valign="top" width="525">
<p><strong><a title="EvenTiles - Episode 5" href="https://mstruys.wordpress.com/2011/12/06/eventiles-from-start-to-finishpart-5/" target="_blank">Using IsolatedStorage</a></strong></p>
<ul>
<li>Storing data in between different times an application executes </li>
<li>Introducing the application life cycle </li>
<li>Using IsolatedStorageSettings to persist information </li>
</ul>
</td>
</tr>
<tr>
<td valign="top" width="525">
<p><a title="EvenTiles - Episode 6" href="https://mstruys.wordpress.com/2011/12/07/eventiles-from-start-to-finishpart-6/" target="_blank"><strong>Using the Isolated Storage Explorer Tool</strong></a></p>
<ul>
<li>Examining the contents of our application’s IsolatedStorage </li>
</ul>
</td>
</tr>
<tr>
<td valign="top" width="525">
<p><strong><a title="EvenTiles - Episode 7" href="https://mstruys.wordpress.com/2011/12/12/eventiles-from-start-to-finishpart-7/" target="_blank">Fast Application Switching and Tombstoning</a></strong></p>
<ul>
<li>A Windows Phone Application’s life cycle </li>
<li>Saving application state when moved to the background </li>
<li>Restoring application state when returning to the foreground </li>
</ul>
</td>
</tr>
<tr>
<td valign="top" width="525">
<p><strong><a title="EvenTiles - Episode 8" href="https://mstruys.wordpress.com/2011/12/14/eventiles-from-start-to-finishpart-8/" target="_blank">More on Tombstoning</a></strong></p>
<ul>
<li>Maintaining Page State </li>
<li>Restoring a page to exactly the same situation it was when the application moved to the background </li>
<li>Restoring focus of input UI elements </li>
</ul>
</td>
</tr>
<tr>
<td valign="top" width="525">
<p><strong><a title="EvenTiles - Episode 9" href="https://mstruys.wordpress.com/2011/12/16/eventiles-from-start-to-finishpart-9/" target="_blank">Creating a Secondary Tile</a></strong></p>
<ul>
<li>Creating a Secondary Tile inside your application </li>
<li>Navigating from the Secondary Tile to the application </li>
<li>Determine if a Secondary Tile is currently visible on the Start screen of a Windows Phone through a lambda expression </li>
<li>Setting the front and back contents of a Secondary Tile </li>
</ul>
</td>
</tr>
<tr>
<td valign="top" width="525">
<p><a title="EvenTiles - Episode 10" href="https://mstruys.wordpress.com/2011/12/21/eventiles-from-start-to-finishpart-10/" target="_blank"><strong>Background Agents</strong></a></p>
<ul>
<li>Different types of Background Agents </li>
<li>Properly creating a PeriodicTask </li>
<li>Starting and stopping a PeriodicTask </li>
<li>Relation between an Application and a Background Agent </li>
</ul>
</td>
</tr>
<tr>
<td valign="top" width="525">
<p><strong><a title="EvenTiles - Episode 11" href="https://mstruys.wordpress.com/2011/12/29/eventiles-from-start-to-finishpart-11/" target="_blank">Debugging Background Agents</a></strong></p>
<ul>
<li>Using conditional compilation to test Background Agents </li>
<li>Properly using the LaunchForTest method </li>
<li>Using the debugger to debug a PeriodicTask </li>
</ul>
</td>
</tr>
<tr>
<td valign="top" width="525">
<p><strong><a title="EvenTiles - Episode 12" href="https://mstruys.wordpress.com/2012/01/05/eventiles-from-start-to-finishpart-12/" target="_blank">The lifetime of PeriodicTask</a></strong></p>
<ul>
<li>Rescheduling a PeriodicTask </li>
<li>Exceptions that might be thrown when scheduling a PeriodicTask </li>
</ul>
</td>
</tr>
<tr>
<td valign="top" width="525">
<p><strong><a title="EvenTiles - Episode 13" href="https://mstruys.wordpress.com/2012/01/08/eventiles-from-start-to-finishpart-13/" target="_blank">Communication between an Application and its PeriodicTask</a></strong></p>
<ul>
<li>Passing data between an application and a PeriodicTask </li>
<li>Protecting variables against simultaneous access by different threads </li>
<li>Using a Mutex to synchronize threads </li>
</ul>
</td>
</tr>
<tr>
<td valign="top" width="525">
<p><strong><a title="EvenTiles - Episode 14" href="https://mstruys.wordpress.com/2012/01/17/eventiles-from-start-to-finishpart-14/" target="_blank">Exchanging data between an Application and its PeriodicTask</a></strong></p>
<ul>
<li>Using a file in IsolatedStorage to exchange data between an application and a PeriodicTask </li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Even though there are many more episodes of EvenTiles planned, attention will now move beyond tiles as we focus on using built-in applications and accessing device hardware.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mstruys.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mstruys.wordpress.com/342/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=342&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mstruys.com/2012/01/28/eventiles-until-now-a-windows-phone-development-series/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef2225df699c5c8ad7ed7c0287d87b41?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mstruys</media:title>
		</media:content>
	</item>
		<item>
		<title>EvenTiles from Start to Finish&#8211;Part 15</title>
		<link>http://mstruys.com/2012/01/26/eventiles-from-start-to-finishpart-15/</link>
		<comments>http://mstruys.com/2012/01/26/eventiles-from-start-to-finishpart-15/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 16:46:00 +0000</pubDate>
		<dc:creator>Maarten Struys</dc:creator>
				<category><![CDATA[Expression Blend]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[Windows Phone SDK 7.1]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">https://mstruys.wordpress.com/?p=339</guid>
		<description><![CDATA[In the previous episode of this series about how to develop a Windows Phone application from scratch you learned how you can transfer data between an application and a PeriodicTask by using a file in IsolatedStorage. With that, the most important functionality of EvenTiles is in place. Today we will add the User Interface for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=339&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In the <a href="https://mstruys.wordpress.com/2012/01/17/eventiles-from-start-to-finishpart-14/" target="_blank">previous episode</a> of this series about how to develop a Windows Phone application from scratch you learned how you can transfer data between an application and a <a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.scheduler.periodictask(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">PeriodicTask</a> by using a file in IsolatedStorage. With that, the most important functionality of EvenTiles is in place. Today we will add the User Interface for an About Page to the application. Since we are not worrying about functionality yet, we will use Expression Blend exclusively in today’s part of the EvenTiles series.</p>
<p>An empty About Page is already part of our EvenTiles solution, and it can already be reached by clicking the corresponding icon on the <a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.shell.applicationbar(v=VS.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">ApplicationBar</a>. The final About Page should look like this (with the upper 4 fields ready to fill in some data programmatically), some explaining text and a few buttons.</p>
<p><a href="http://mstruys.files.wordpress.com/2012/01/image6.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;float:left;padding-top:0;border-width:0;margin:0 5px 0 0;" title="image" border="0" alt="image" align="left" src="http://mstruys.files.wordpress.com/2012/01/image_thumb6.png?w=132&#038;h=240" width="132" height="240" /></a>The UI of the About Page is not that complex as you can see. It consists of a <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.grid(v=vs.95).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">Grid</a> Control containing a <a href="http://msdn.microsoft.com/en-us/library/ms609067(v=vs.95).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">Border</a> Control, a <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.textblock(v=vs.95).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">TextBlock</a> and a number of <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.button(v=vs.95).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">Buttons</a>, each on separate rows. All rows containing UI Elements have their height defined as auto. To complete the layout, two empty rows are also defined that fill up unused space on the page.</p>
<p>The Border Control contains another Grid Control which in turn contains 4 rows and 2 columns, all containing TextBlocks. The TextBlock that holds the version number of the application will be filled programmatically with the assembly version number that is defined for the application. The color of the Border Control and of the TextBlocks inside it is defined to be the accent color, so it will automatically change when the user changes the theme colors on the phone.</p>
<p>To keep the margins for text in each TextBlock consistent, we make sure to use one of the predefined styles on them from inside Expression Blend (all are using a <a href="http://msdn.microsoft.com/en-us/library/ff769552(v=VS.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">PhoneTextNormalStyle</a>). If you want to learn more about creating consistent user interfaces for Windows Phone pages, you should take a look at this <a href="http://www.jeff.wilcox.name/2012/01/metroradio-design/" target="_blank">excellent blog article from Jeff Wilcox</a> with great tips on Metro Design. </p>
<p><a href="http://mstruys.files.wordpress.com/2012/01/image7.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:5px 0;" title="image" border="0" alt="image" src="http://mstruys.files.wordpress.com/2012/01/image_thumb7.png?w=520&#038;h=312" width="520" height="312" /></a></p>
<p>In order to nicely divide a number of UI elements over the About Page, we are making use of the ContentPanel Grid. Inside that Grid, we define a few more Rows than we actually need, just to make sure that our layout looks good. </p>
<p><a href="http://mstruys.files.wordpress.com/2012/01/dump5.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;float:left;border-top:0;border-right:0;padding-top:0;margin:5px 5px 5px 0;" title="dump5" border="0" alt="dump5" align="left" src="http://mstruys.files.wordpress.com/2012/01/dump5_thumb.jpg?w=195&#038;h=354" width="195" height="354" /></a></p>
<p>You can see that in the this screen shot, where all rows and columns are visible. The dotted lines show all rows and columns available, both for the Grid inside the Border and for the entire ContentPanel. In the ContentPanel you see two blank rows, they are used to fill up unused space on the page, by specifying their height to be of size “<strong>1*</strong>”. All the other rows are using the height they need by specifying their height to be <strong>auto</strong>.</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>The other thing that is noticeable, is the image to the left of the text inside the upper button. This button is created with a <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.stackpanel(v=vs.95).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">StackPanel</a> defining its Content area. The StackPanel holds both an <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.image(v=vs.95).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">Image</a> and a TextBlock and is defined as follows in XAML:</p>
<p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b0f00ce7-1b27-476f-890c-40df1b3a70af" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">XAML to define &#8216;email&#8217; button</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;white-space:nowrap;margin:0;padding:0 0 0 5px;">
<li><span style="color:#0000ff;">&lt;</span><span style="color:#a31515;">Button</span><span style="color:#ff0000;"> x</span><span style="color:#0000ff;">:</span><span style="color:#ff0000;">Name</span><span style="color:#0000ff;">=&quot;btnEmail&quot;</span></li>
<li style="background:#f3f3f3;">       <span style="color:#ff0000;"> Grid.Row</span><span style="color:#0000ff;">=&quot;4&quot;&gt;</span></li>
<li>    <span style="color:#a31515;"></span><span style="color:#0000ff;">&lt;</span><span style="color:#a31515;">StackPanel</span><span style="color:#ff0000;"> Orientation</span><span style="color:#0000ff;">=&quot;Horizontal&quot;&gt;</span></li>
<li style="background:#f3f3f3;">        <span style="color:#a31515;"></span><span style="color:#0000ff;">&lt;</span><span style="color:#a31515;">Image</span><span style="color:#ff0000;"> Source</span><span style="color:#0000ff;">=&quot;appbar.feature.email.rest.png&quot; /&gt;</span></li>
<li>        <span style="color:#a31515;"></span><span style="color:#0000ff;">&lt;</span><span style="color:#a31515;">TextBlock</span><span style="color:#ff0000;"> TextWrapping</span><span style="color:#0000ff;">=&quot;Wrap&quot;</span></li>
<li style="background:#f3f3f3;">                   <span style="color:#ff0000;"> Text</span><span style="color:#0000ff;">=&quot;Email feedback / suggestions&quot;</span></li>
<li>                   <span style="color:#ff0000;"> VerticalAlignment</span><span style="color:#0000ff;">=&quot;Center&quot;</span></li>
<li style="background:#f3f3f3;">                   <span style="color:#ff0000;"> Style</span><span style="color:#0000ff;">=&quot;{</span><span style="color:#a31515;">StaticResource</span><span style="color:#ff0000;"> PhoneTextNormalStyle}</span><span style="color:#0000ff;">&quot; /&gt;</span></li>
<li>    <span style="color:#a31515;"></span><span style="color:#0000ff;">&lt;/</span><span style="color:#a31515;">StackPanel</span><span style="color:#0000ff;">&gt;</span></li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">&lt;/</span><span style="color:#a31515;">Button</span><span style="color:#0000ff;">&gt;</span></li>
</ol></div>
</p></div>
</p></div>
</p>
<p>You can also see that we simply re-use the email icon that ships with the tools for use in an ApplicationBar. Of course it is rather hard to show how to create a user interface inside a blog article. Most likely it makes more sense for this episode of EvenTiles to watch the accompanying video, in which you can see how the entire user interface for this page was created using Expression Blend.</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:efb46574-88f6-42d0-bfc6-4be44b1c8ffb" class="wlWriterEditableSmartContent">
<div><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='448' height='252' src='http://www.youtube.com/embed/LcqP7RHxbw0?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;hd=1&#038;wmode=transparent' frameborder='0'></iframe></span></div>
<div style="width:448px;clear:both;font-size:.8em;">Creating an About Page for a Windows Phone Application with Expression Blend</div>
</div>
<p>In the next episode of EvenTiles we return to actual programming, when we add functionality to the AboutPage to access MarketPlace, to submit application reviews and to use a Launcher to create / send an email message. You will also learn how to retrieve the application’s version number programmatically. Just make sure to return to this blog regularly or to subscribe to the RSS feed.</p>
<p><a href="http://www.windowsphone.com/en-US/apps/27024895-5091-4ebb-8f2a-89e34cd9f9ee" target="_blank"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;float:left;padding-top:0;border-width:0;margin:8px 5px 5px 0;" border="0" alt="EvenTiles" align="left" src="http://catalog.zune.net/v3.2/en-US/apps/27024895-5091-4ebb-8f2a-89e34cd9f9ee/primaryImage?width=95&amp;height=95&amp;resize=true" /></a>If you want to see EvenTiles already in action on your Windows Phone, you can also install the latest version from Marketplace. Remember that this application is not meant to be extremely useful, although it contains similar functionality that “serious” applications have. Just go ahead and get your free copy of EvenTiles from Marketplace at this location: <a href="http://www.windowsphone.com/en-US/search?q=EvenTiles" target="_blank">http://www.windowsphone.com/en-US/search?q=EvenTiles</a> (or search on your phone for EvenTiles in the Marketplace application).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mstruys.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mstruys.wordpress.com/339/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=339&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mstruys.com/2012/01/26/eventiles-from-start-to-finishpart-15/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef2225df699c5c8ad7ed7c0287d87b41?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mstruys</media:title>
		</media:content>

		<media:content url="http://mstruys.files.wordpress.com/2012/01/image_thumb6.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://mstruys.files.wordpress.com/2012/01/image_thumb7.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://mstruys.files.wordpress.com/2012/01/dump5_thumb.jpg" medium="image">
			<media:title type="html">dump5</media:title>
		</media:content>

		<media:content url="http://catalog.zune.net/v3.2/en-US/apps/27024895-5091-4ebb-8f2a-89e34cd9f9ee/primaryImage?width=95&#38;height=95&#38;resize=true" medium="image">
			<media:title type="html">EvenTiles</media:title>
		</media:content>
	</item>
		<item>
		<title>MessageBox, Navigation and Application Life Cycle</title>
		<link>http://mstruys.com/2012/01/19/messagebox-navigation-and-application-life-cycle/</link>
		<comments>http://mstruys.com/2012/01/19/messagebox-navigation-and-application-life-cycle/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 17:31:00 +0000</pubDate>
		<dc:creator>Maarten Struys</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Windows Phone SDK 7.1]]></category>
		<category><![CDATA[XNA Framework]]></category>
		<category><![CDATA[BeginShowMessageBox]]></category>
		<category><![CDATA[MessageBox]]></category>
		<category><![CDATA[Tombstoning]]></category>

		<guid isPermaLink="false">https://mstruys.wordpress.com/?p=330</guid>
		<description><![CDATA[One of our applications failed certification today because of an issue I should have known about. Even though the scenario in which an exception occurs is fairly easy, solving the problem properly involves a little work and a little thinking. Other blog entries have been written about this particular problem, although suggested solutions did not [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=330&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>One of our applications failed certification today because of an issue I should have known about. Even though the scenario in which an exception occurs is fairly easy, solving the problem properly involves a little work and a little thinking. Other blog entries have been written about this particular problem, although suggested solutions did not seem to work for me. Let me first show the original code:</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ace6cdd5-3ff6-44b6-8d0f-85daf977bfe5" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">MessageBox and Navigation</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> TurnCard_Click(<span style="color:#0000ff;">object</span> sender, System.Windows.<span style="color:#2b91af;">RoutedEventArgs</span> e)</li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#2b91af;">MessageBoxResult</span> mr = <span style="color:#2b91af;">MessageBoxResult</span>.Cancel;</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>    <span style="color:#0000ff;">if</span> (nrTimesClicked &gt; 2)</li>
<li style="background:#f3f3f3;">    {</li>
<li>        mr = <span style="color:#2b91af;">MessageBox</span>.Show(<span style="color:#a31515;">&quot;Continuing now might confuse you. Try again tomorrow?&quot;</span>, </li>
<li style="background:#f3f3f3;">            <span style="color:#a31515;">&quot;Continuing tomorrow?&quot;</span>, <span style="color:#2b91af;">MessageBoxButton</span>.OKCancel);</li>
<li>    }</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>    <span style="color:#0000ff;">if</span> (mr == <span style="color:#2b91af;">MessageBoxResult</span>.OK)</li>
<li style="background:#f3f3f3;">    {</li>
<li>        NavigationService.GoBack();</li>
<li style="background:#f3f3f3;">    }</li>
<li>    <span style="color:#0000ff;">else</span></li>
<li style="background:#f3f3f3;">    {</li>
<li>        <span style="color:#2b91af;">Random</span> r = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">Random</span>();</li>
<li style="background:#f3f3f3;">        <span style="color:#0000ff;">int</span> card = r.Next(cardPages.Length);</li>
<li>        NavigationService.Navigate(<span style="color:#0000ff;">new</span> <span style="color:#2b91af;">Uri</span>(cardPages[card], <span style="color:#2b91af;">UriKind</span>.Relative));</li>
<li style="background:#f3f3f3;">        nrTimesClicked++;</li>
<li>    }</li>
<li style="background:#f3f3f3;">}</li>
</ol></div>
</p></div>
</p></div>
<p>Running this code and clicking the Start button on the phone while the <a href="http://msdn.microsoft.com/en-us/library/system.windows.messagebox(v=VS.95).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">MessageBox</a> is visible results in the following exception when running with the debugger attached (it results in an application termination when running stand-alone):</p>
<p><a href="http://mstruys.files.wordpress.com/2012/01/image4.png"><img style="background-image:none;margin:5px 0;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" border="0" alt="image" src="http://mstruys.files.wordpress.com/2012/01/image_thumb4.png?w=528&#038;h=80" width="528" height="80" /></a></p>
<p>The <a href="http://msdn.microsoft.com/en-us/library/system.windows.navigation.navigationservice.navigationfailed(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">NavigationFailed</a> event is raised. This is caused by the fact that the MessageBox returns when clicking the phone’s Start button with a return value of <a href="http://msdn.microsoft.com/en-us/library/system.windows.messageboxbutton(v=vs.95).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">MessageBoxResult.Cancel</a>. Since in the above code fragment, the Cancel button is used to navigate to some page, even though the application is supposed to go to the background in order to display the start screen on the phone, navigation fails. The interesting part is that the application does not have a clue that the user pressed the Start button on the phone. So some thinking is required to fix this issue.</p>
<p>Single stepping through the problematic method TurnCard_Click showed another behavior:</p>
<p><a href="http://mstruys.files.wordpress.com/2012/01/image5.png"><img style="background-image:none;margin:5px 0;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" border="0" alt="image" src="http://mstruys.files.wordpress.com/2012/01/image_thumb5.png?w=524&#038;h=214" width="524" height="214" /></a></p>
<p>This at least made clear that indeed the call to the NavigationService caused the problem. To solve the problem, what can be done is protecting calls to the NavigationService by catching this particular exception:</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c09de87c-f58d-4c00-8ecb-c6df88754d6c" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Protecting the Navigate method</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> TurnCard_Click(<span style="color:#0000ff;">object</span> sender, System.Windows.<span style="color:#2b91af;">RoutedEventArgs</span> e)</li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#2b91af;">MessageBoxResult</span> mr = <span style="color:#2b91af;">MessageBoxResult</span>.Cancel;</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>    <span style="color:#0000ff;">if</span> (nrTimesClicked &gt; 2)</li>
<li style="background:#f3f3f3;">    {</li>
<li>        mr = <span style="color:#2b91af;">MessageBox</span>.Show(<span style="color:#a31515;">&quot;Continuing now might confuse you. Try again tomorrow?&quot;</span>, </li>
<li style="background:#f3f3f3;">            <span style="color:#a31515;">&quot;Continuing tomorrow?&quot;</span>, <span style="color:#2b91af;">MessageBoxButton</span>.OKCancel);</li>
<li>    }</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>    <span style="color:#0000ff;">if</span> (mr == <span style="color:#2b91af;">MessageBoxResult</span>.OK)</li>
<li style="background:#f3f3f3;">    {</li>
<li>        NavigationService.GoBack();</li>
<li style="background:#f3f3f3;">    }</li>
<li>    <span style="color:#0000ff;">else</span></li>
<li style="background:#f3f3f3;">    {</li>
<li>        <span style="color:#2b91af;">Random</span> r = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">Random</span>();</li>
<li style="background:#f3f3f3;">        <span style="color:#0000ff;">int</span> card = r.Next(cardPages.Length);</li>
<li>        <span style="color:#0000ff;">try</span></li>
<li style="background:#f3f3f3;">        {</li>
<li>            NavigationService.Navigate(<span style="color:#0000ff;">new</span> <span style="color:#2b91af;">Uri</span>(cardPages[card], <span style="color:#2b91af;">UriKind</span>.Relative));</li>
<li style="background:#f3f3f3;">        }</li>
<li>        <span style="color:#0000ff;">catch</span> (<span style="color:#2b91af;">InvalidOperationException</span>)</li>
<li style="background:#f3f3f3;">        {</li>
<li>            ;</li>
<li style="background:#f3f3f3;">        }</li>
<li>        nrTimesClicked++;</li>
<li style="background:#f3f3f3;">    }</li>
<li>}</li>
</ol></div>
</p></div>
</p></div>
<p>This does solve the problem, although I don’t like it that an exception is thrown in a situation that the operating system should somehow prevent us against (maybe by returning some other value when the MessageBox returns without the user clicking on one of its buttons). If you want to have a little more flexibility, and don’t mind coding a bit more, there is another possible solution. Instead of using a MessageBox, you can make use of the <a href="http://msdn.microsoft.com/en-us/library/dd940233(v=xnagamestudio.40).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">Guide.BeginShowMessageBox</a> method that is defined in the XNA Framework. This method is a bit more complex, but also much more flexible then its Silverlight counterpart. BeginShowMessageBox is asynchronous, which means that you need to take care with calling code that is supposed to run on the UI Thread.</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:890ca387-ab76-4490-add4-a1c45c26ef82" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Using BeginShowMessageBox</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> TurnCard_Click(<span style="color:#0000ff;">object</span> sender, System.Windows.<span style="color:#2b91af;">RoutedEventArgs</span> e)</li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#0000ff;">if</span> (nrTimesClicked &gt; 2)</li>
<li style="background:#f3f3f3;">    {</li>
<li>        ShowContinueMessage();</li>
<li style="background:#f3f3f3;">    }</li>
<li>    <span style="color:#0000ff;">else</span></li>
<li style="background:#f3f3f3;">    {</li>
<li>        <span style="color:#2b91af;">Random</span> r = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">Random</span>();</li>
<li style="background:#f3f3f3;">        <span style="color:#0000ff;">int</span> card = r.Next(cardPages.Length);</li>
<li>        nrTimesClicked++;</li>
<li style="background:#f3f3f3;">        NavigationService.Navigate(<span style="color:#0000ff;">new</span> <span style="color:#2b91af;">Uri</span>(cardPages[card], <span style="color:#2b91af;">UriKind</span>.Relative));</li>
<li>    }</li>
<li style="background:#f3f3f3;">}</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> ShowContinueMessage()</li>
<li>{</li>
<li style="background:#f3f3f3;">    <span style="color:#2b91af;">List</span>&lt;<span style="color:#0000ff;">string</span>&gt; mbOptions = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">List</span>&lt;<span style="color:#0000ff;">string</span>&gt;();</li>
<li>    mbOptions.Add(<span style="color:#a31515;">&quot;OK&quot;</span>);</li>
<li style="background:#f3f3f3;">    mbOptions.Add(<span style="color:#a31515;">&quot;Cancel&quot;</span>);</li>
<li>    <span style="color:#0000ff;">string</span> msg = <span style="color:#a31515;">&quot;Continuing now might confuse you. Try again tomorrow?&quot;</span>;</li>
<li style="background:#f3f3f3;">    <span style="color:#0000ff;">string</span> title = <span style="color:#a31515;">&quot;Continuing tomorrow?&quot;</span>;</li>
<li>    <span style="color:#2b91af;">Guide</span>.BeginShowMessageBox(title, msg, mbOptions, 0, <span style="color:#2b91af;">MessageBoxIcon</span>.Alert, EnteredAnswer, <span style="color:#0000ff;">null</span>);</li>
<li style="background:#f3f3f3;">    messageBoxVisible = <span style="color:#0000ff;">true</span>;</li>
<li>}</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> EnteredAnswer(<span style="color:#2b91af;">IAsyncResult</span> ar)</li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#0000ff;">int</span>? result = <span style="color:#2b91af;">Guide</span>.EndShowMessageBox(ar);</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>    <span style="color:#0000ff;">if</span> (result != <span style="color:#0000ff;">null</span>)</li>
<li style="background:#f3f3f3;">    {</li>
<li>        messageBoxVisible = <span style="color:#0000ff;">false</span>;</li>
<li style="background:#f3f3f3;">    }</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;">    <span style="color:#0000ff;">if</span> (result != <span style="color:#0000ff;">null</span> &amp;&amp; result == 0)</li>
<li>    {</li>
<li style="background:#f3f3f3;">        <span style="color:#0000ff;">this</span>.Dispatcher.BeginInvoke(<span style="color:#0000ff;">delegate</span></li>
<li>        {</li>
<li style="background:#f3f3f3;">            NavigationService.GoBack();</li>
<li>        });</li>
<li style="background:#f3f3f3;">    }</li>
<li>    <span style="color:#0000ff;">else</span> <span style="color:#0000ff;">if</span> (result != <span style="color:#0000ff;">null</span>)</li>
<li style="background:#f3f3f3;">    {</li>
<li>        <span style="color:#2b91af;">Random</span> r = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">Random</span>();</li>
<li style="background:#f3f3f3;">        <span style="color:#0000ff;">int</span> card = r.Next(cardPages.Length);</li>
<li>        <span style="color:#0000ff;">this</span>.Dispatcher.BeginInvoke(<span style="color:#0000ff;">delegate</span></li>
<li style="background:#f3f3f3;">        {</li>
<li>            NavigationService.Navigate(<span style="color:#0000ff;">new</span> <span style="color:#2b91af;">Uri</span>(cardPages[card], <span style="color:#2b91af;">UriKind</span>.Relative));</li>
<li style="background:#f3f3f3;">        });</li>
<li>    }</li>
<li style="background:#f3f3f3;">}</li>
</ol></div>
</p></div>
</p></div>
<p>The interesting code can be found in the EnteredAnswer method, where we retrieve the key the user entered in the message box. Since <a href="http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.gamerservices.guide.endshowmessagebox(v=xnagamestudio.40).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">EndShowMessageBox</a> returns a <a href="http://msdn.microsoft.com/en-us/library/1t3y8s4s(v=vs.80).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">nullable</a> integer, it has this nice way of using null in those cases where the user did not click any key (in other words, for instance when the message box is removed as a result of the application going to the background). So now we have a way of detecting if we can navigate (result has a value other then null). The sample code also sets a boolean variable <font size="2" face="Courier New">messageBoxVisible</font>, which is used in combination with <a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.controls.phoneapplicationpage.state(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">PhoneApplicationPage.State</a> to display the message box again when the user returns to the application. Hopefully this time the application will pass certification.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mstruys.wordpress.com/330/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mstruys.wordpress.com/330/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=330&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mstruys.com/2012/01/19/messagebox-navigation-and-application-life-cycle/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef2225df699c5c8ad7ed7c0287d87b41?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mstruys</media:title>
		</media:content>

		<media:content url="http://mstruys.files.wordpress.com/2012/01/image_thumb4.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://mstruys.files.wordpress.com/2012/01/image_thumb5.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>EvenTiles from Start to Finish&#8211;Part 14</title>
		<link>http://mstruys.com/2012/01/17/eventiles-from-start-to-finishpart-14/</link>
		<comments>http://mstruys.com/2012/01/17/eventiles-from-start-to-finishpart-14/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 17:20:00 +0000</pubDate>
		<dc:creator>Maarten Struys</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[Windows Phone SDK 7.1]]></category>
		<category><![CDATA[Background Processing]]></category>
		<category><![CDATA[IsolatedStorage]]></category>
		<category><![CDATA[PeriodicTask]]></category>

		<guid isPermaLink="false">https://mstruys.wordpress.com/?p=323</guid>
		<description><![CDATA[In the previous episode of this series about how to develop a Windows Phone application from scratch we found out that special care must be taken when data must be passed between an application and its PeriodicTask. You learned how data can be protected against mutual access by using a Mutex object. You also learned [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=323&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In the <a href="https://mstruys.wordpress.com/2012/01/08/eventiles-from-start-to-finishpart-13/" target="_blank">previous episode</a> of this series about how to develop a Windows Phone application from scratch we found out that special care must be taken when data must be passed between an application and its <a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.scheduler.periodictask(v=vs.92).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">PeriodicTask</a>. You learned how data can be protected against mutual access by using a Mutex object. You also learned that you cannot pass data directly from one to another, because the application and its PeriodicTask execute inside different processes.</p>
<p>In this episode of EvenTiles you will learn how you can make use of <a href="http://msdn.microsoft.com/en-us/library/x7dzh4ws(v=vs.95).aspx?ocid=aff-n-we-loc--ITPRO40898&amp;WT.mc_id=aff-n-we-loc--ITPRO40898" target="_blank">IsolatedStorage</a> to pass data from the application to the PeriodicTask. Since we already created a separate project in the EvenTiles solution that is taking care of passing data, we can simply modify functionality in that project (EvenTilesComm) to use a file to pass data between the application and its PeriodicTask. Data protection against mutual access is already in place, so we can concentrate on file access. Hopefully the design decision in <a href="https://mstruys.wordpress.com/2012/01/08/eventiles-from-start-to-finishpart-13/" target="_blank">part 13</a> to make use of private methods that are called each time we access a public property inside the TileData class starts to make sense now.</p>
<p>What we want to achieve is the following:</p>
<ul>
<li>From inside the application we can store a string containing content for the backside of a Secondary Tile in a file at any time </li>
<li>Our PeriodicTask executes approximately once per 30 minutes and it either displays the string passed by the application on the backside of the Secondary Tile or it displays a default string that is defined inside the PeriodicTask </li>
<li>The content of the backside of the Secondary Tile needs to toggle each time the PeriodicTask executes </li>
<li>If the EvenTiles user modifies the string to be displayed inside the Settings page, it will immediately be displayed on the Secondary Tile (if it exists) </li>
</ul>
<p>In order to pass data between the application and the PeriodicTask we will extend the private retrieve / store methods inside the TileData class by adding a call to a couple of other private methods. Those new private methods will use a file in IsolatedStorage to read / write data from, meaning we can effectively pass data between the application and its PeriodicTask.</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4675ee8b-9a25-46bf-8dcd-ca6288f1bad5" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Properties to access Tile Data</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;white-space:nowrap;margin:0;padding:0 0 0 5px;">
<li><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">string</span> RetrieveSecondaryBackContent()</li>
<li style="background:#f3f3f3;">{</li>
<li>    mtx.WaitOne();</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>    <span style="color:#0000ff;">try</span></li>
<li style="background:#f3f3f3;">    {</li>
<li>        RetrieveTileContent();</li>
<li style="background:#f3f3f3;">        <span style="color:#0000ff;">return</span> secondaryBackContent;</li>
<li>    }</li>
<li style="background:#f3f3f3;">    <span style="color:#0000ff;">finally</span></li>
<li>    {</li>
<li style="background:#f3f3f3;">        mtx.ReleaseMutex();</li>
<li>    }</li>
<li style="background:#f3f3f3;">}</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> StoreSecondaryBackContent(<span style="color:#0000ff;">string</span> content)</li>
<li>{</li>
<li style="background:#f3f3f3;">    mtx.WaitOne();</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;">    <span style="color:#0000ff;">try</span></li>
<li>    {</li>
<li style="background:#f3f3f3;">        secondaryBackContent = content;</li>
<li>        PersistTileContent();</li>
<li style="background:#f3f3f3;">    }</li>
<li>    <span style="color:#0000ff;">finally</span></li>
<li style="background:#f3f3f3;">    {</li>
<li>        mtx.ReleaseMutex();</li>
<li style="background:#f3f3f3;">    }</li>
<li>}</li>
</ol></div>
</p></div>
</p></div>
<p>A new string to be displayed on the back side of a Secondary Tile will be stored by the application each time users modify their own tile text in the Settings Page of the EvenTiles application (something that will also be done initially when the application starts). The PeriodicTask simply retrieves that data (since now the data is persisted in a file this will work properly) and displays it on the back side of the Secondary Tile. Each time data needs to be stored a new file is created in IsolatedStorage or an existing file is overwritten. Each time data needs to be retrieved, we check if a file containing that data exists. There are small ways to optimize data access in the TileData class, because right now we simply read / write all file content when retrieving / storing single property values. However, this approach simplifies the code and the overhead with only two different variables is very small.</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b62353ee-4201-459d-a60a-7439b3713cdf" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Using IsolatedStorage</div>
<div style="background:#fff;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;white-space:nowrap;margin:0;padding:0 0 0 5px;">
<li><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">const</span> <span style="color:#0000ff;">string</span> contentFileName = <span style="color:#a31515;">&quot;EvenTileContent.txt&quot;</span>;</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> PersistTileContent()</li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#0000ff;">using</span> (<span style="color:#0000ff;">var</span> store = <span style="color:#2b91af;">IsolatedStorageFile</span>.GetUserStoreForApplication())</li>
<li style="background:#f3f3f3;">    {</li>
<li>        <span style="color:#0000ff;">using</span> (<span style="color:#0000ff;">var</span> contentStream = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">StreamWriter</span>(store.CreateFile(contentFileName)))</li>
<li style="background:#f3f3f3;">        {</li>
<li>            contentStream.WriteLine(showDefaultSecondaryBackContent.ToString());</li>
<li style="background:#f3f3f3;">            contentStream.WriteLine(secondaryBackContent);</li>
<li>        }</li>
<li style="background:#f3f3f3;">    }</li>
<li>}</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> RetrieveTileContent()</li>
<li style="background:#f3f3f3;">{</li>
<li>    <span style="color:#0000ff;">using</span> (<span style="color:#0000ff;">var</span> store = <span style="color:#2b91af;">IsolatedStorageFile</span>.GetUserStoreForApplication())</li>
<li style="background:#f3f3f3;">    {</li>
<li>        <span style="color:#0000ff;">if</span> (store.FileExists(contentFileName))</li>
<li style="background:#f3f3f3;">        {</li>
<li>            <span style="color:#0000ff;">using</span> (<span style="color:#0000ff;">var</span> contentStream = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">StreamReader</span>(store.OpenFile(contentFileName, <span style="color:#2b91af;">FileMode</span>.Open)))</li>
<li style="background:#f3f3f3;">            {</li>
<li>                showDefaultSecondaryBackContent = <span style="color:#2b91af;">Convert</span>.ToBoolean(contentStream.ReadLine());</li>
<li style="background:#f3f3f3;">                secondaryBackContent = contentStream.ReadToEnd();</li>
<li>            }</li>
<li style="background:#f3f3f3;">        }</li>
<li>    }</li>
<li style="background:#f3f3f3;">}</li>
</ol></div>
</p></div>
</p></div>
<p>With the way we organized the functionality inside the TileData class in the previous episode of this development series, these are the only new methods necessary in order to pass data. When the user installs a Secondary Tile for the EvenTiles application and modifies its back string content through the Settings page, this is the result (changing the back content of the Secondary Tile every 30 minutes):</p>
<p><a href="http://mstruys.files.wordpress.com/2012/01/image3.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:5px 0;" title="image" border="0" alt="image" src="http://mstruys.files.wordpress.com/2012/01/image_thumb3.png?w=526&#038;h=217" width="526" height="217" /></a></p>
<p>The following video shows EvenTiles in action with proper transfer of data between the application and its PeriodicTask. </p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:147891ff-6b98-4698-94d5-c2f530d76314" class="wlWriterEditableSmartContent">
<div><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='448' height='252' src='http://www.youtube.com/embed/GgWQeGokaYU?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;hd=1&#038;wmode=transparent' frameborder='0'></iframe></span></div>
<div style="width:448px;clear:both;font-size:.8em;">Data transfer between an Application and a PeriodicTask through IsolatedStorage</div>
</div>
<p>To be able to experiment with this working implementation of EvenTiles, especially to understand how the application interacts with the PeriodicTask through a file in IsolatedStorage, the sample code is available for <a href="https://skydrive.live.com/redir.aspx?cid=3302ab496146f161&amp;resid=3302AB496146F161!5895&amp;parid=3302AB496146F161!5870&amp;authkey=!AN88UJ1LTX8Q4X0">dowload here</a>. </p>
<p>Right now we have the basic functionality of EvenTiles more or less ready, although the About Page still needs to get some content. That is something we will work on in the next part of EvenTiles. After that we will cover much more in the upcoming episodes of EvenTiles including but not limited to</p>
<ul>
<li>using ads in the application </li>
<li>retrieving location information inside the application </li>
<li>taking pictures </li>
<li>modifying pictures </li>
<li>using alarms and notifications </li>
<li>using Visual Studio’s integrated Performance Analysis to find performance bottlenecks inside the application </li>
<li>submitting the application for certification </li>
</ul>
<p>EvenTiles will continue soon so stay tuned for the next episode.</p>
<blockquote><p><a href="http://www.windowsphone.com/en-US/apps/27024895-5091-4ebb-8f2a-89e34cd9f9ee" target="_blank"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;float:left;padding-top:0;border-width:0;margin:8px 5px 5px 0;" border="0" alt="EvenTiles" align="left" src="http://catalog.zune.net/v3.2/en-US/apps/27024895-5091-4ebb-8f2a-89e34cd9f9ee/primaryImage?width=95&amp;height=95&amp;resize=true" /></a>If you want to see EvenTiles already in action on your Windows Phone, you can also install the latest version from Marketplace. Remember that this application is not meant to be extremely useful, although it contains similar functionality that “serious” applications have. Just go ahead and get your free copy of EvenTiles from Marketplace at this location: <a href="http://www.windowsphone.com/en-US/search?q=EvenTiles" target="_blank">http://www.windowsphone.com/en-US/search?q=EvenTiles</a> (or search on your phone for EvenTiles in the Marketplace application).</p>
</blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mstruys.wordpress.com/323/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mstruys.wordpress.com/323/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mstruys.com&#038;blog=18427180&#038;post=323&#038;subd=mstruys&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mstruys.com/2012/01/17/eventiles-from-start-to-finishpart-14/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef2225df699c5c8ad7ed7c0287d87b41?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mstruys</media:title>
		</media:content>

		<media:content url="http://mstruys.files.wordpress.com/2012/01/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://catalog.zune.net/v3.2/en-US/apps/27024895-5091-4ebb-8f2a-89e34cd9f9ee/primaryImage?width=95&#38;height=95&#38;resize=true" medium="image">
			<media:title type="html">EvenTiles</media:title>
		</media:content>
	</item>
	</channel>
</rss>
