<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.microsoft.co.il/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Alex Golesh&amp;#39;s Blog About Silverlight Development : Windows, XAML</title><link>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows/XAML/default.aspx</link><description>Tags: Windows, XAML</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>Windows 8 Live Tiles – take 2</title><link>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2013/01/28/windows-8-live-tiles-take-2.aspx</link><pubDate>Tue, 29 Jan 2013 02:57:28 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1709389</guid><dc:creator>Alex Golesh</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/rsscomments.aspx?PostID=1709389</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/commentapi.aspx?PostID=1709389</wfw:comment><comments>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2013/01/28/windows-8-live-tiles-take-2.aspx#comments</comments><description>&lt;p&gt;Quite some time ago I blogged about &lt;a href="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-live-tiles-toasts-badges-and-push-notifications-part-10-11.aspx" target="_blank"&gt;Live Tiles &amp;amp; Toast Notifications Windows 8&lt;/a&gt; feature.&lt;/p&gt;  &lt;p&gt;About a week ago I was delivering Windows 8 training and as a part of this course was delivering a sessions about Live Tiles and Windows 8 PLM (PLM = Process Lifetime Management, session which discusses when Windows 8 runs apps and some point about Windows 8 background tasks). The PLM session mentions, that Windows 8 apps are permitted to run background tasks, but they will be executed approximately once in 2 hour and will be getting few seconds of CPU time. I’ve also mentioned, that some apps, which got user permission to run under the lock screen will be able to run the background tasks based on system timer, but those apps will be scheduling to run once in 15 minutes as minimum timeslot between the execution. Right after the PLM session, at the break, one of my students came to me and asked how “clock” live tiles applications (already few published in the Store) are working. I had to admit, that I never saw this apps before and was not aware about them and how do they working. The student pointed out on one of them and after installing the app I saw that the app go a live tile with current clock and it updates the tile once in a minute. I have to admit, I was intrigued…&lt;/p&gt;  &lt;p&gt;I checked the app permissions – it used background permissions, but this was not enough to update a tile once in a minute (remember – the minimum timeslot for such apps are 15 minutes). Then (after briefly chatting about this with my friend and colleague from MS DPE) I assumed that app probably uses push notifications. After further thoughts I failed also this option as the app is free and pushing 1440 messages daily per client is way above free limit of push notifications. I double checked myself by disconnecting network connections on my laptop to make sure. The app keep working and updated the tile. And suddenly it hit me – the app uses Scheduled Toast Notifications! It is possible to schedule many future toasts (I don’t remember exact number, but way more than 15 (needed for background service with lock screen permissions) and more than 120 (needed for regular background service). I tried to repro the app and here it is – for the sake of simplicity I didn’t create images of all minutes per day (actually half is enough as analogue clock has the same presentation once in 12 hours). Also I decided to make a sample without background service as for my demo it was not rally needed.&lt;/p&gt;  &lt;p&gt;So I’ve create the super simple UI which gets a count number from user:&lt;/p&gt;  &lt;div id="codeSnippetWrapper" style="overflow:auto;cursor:text;font-size:8pt;border-top:silver 1px solid;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-right:silver 1px solid;border-bottom:silver 1px solid;padding-bottom:4px;direction:ltr;text-align:left;padding-top:4px;padding-left:4px;margin:20px 0px 10px;border-left:silver 1px solid;line-height:12pt;padding-right:4px;max-height:200px;width:97.5%;background-color:#f4f4f4;"&gt;   &lt;div id="codeSnippet" style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;     &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Grid&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;Background&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{StaticResource ApplicationPageBackgroundThemeBrush}&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;TextBox&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;x:Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;txtCount&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;10&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;MaxHeight&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;40&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;MaxWidth&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;40&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;HorizontalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Left&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Button&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;Content&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Set&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;Click&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Button_Click_1&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;Grid&lt;/span&gt;.&lt;span style="color:#ff0000;"&gt;Row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;And here is button click event handler:&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="overflow:auto;cursor:text;font-size:8pt;border-top:silver 1px solid;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-right:silver 1px solid;border-bottom:silver 1px solid;padding-bottom:4px;direction:ltr;text-align:left;padding-top:4px;padding-left:4px;margin:20px 0px 10px;border-left:silver 1px solid;line-height:12pt;padding-right:4px;max-height:200px;width:97.5%;background-color:#f4f4f4;"&gt;
  &lt;div id="codeSnippet" style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;
    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Button_Click_1(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;{&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;    &lt;span style="color:#008000;"&gt;//Remove old scheduled notifications as we are starting new countdown&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;    var oldNotifications = TileUpdateManager.CreateTileUpdaterForApplication().GetScheduledTileNotifications();&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;    &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (var item &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; oldNotifications)&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;        TileUpdateManager.CreateTileUpdaterForApplication().RemoveFromSchedule(item);&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;    &lt;span style="color:#008000;"&gt;//Parse user input and get current time&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;    &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; val = &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;.Parse(txtCount.Text);&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;    DateTime startTime = DateTime.Now;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;    &lt;span style="color:#008000;"&gt;//Set &amp;quot;Ready, Set, Go!&amp;quot; tile - displayed immediately&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;    ITileSquareText01 tile0 = TileContentFactory.CreateTileSquareText01();&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;    tile0.TextHeading.Text = &lt;span style="color:#006080;"&gt;&amp;quot;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;    tile0.TextBody1.Text = &lt;span style="color:#006080;"&gt;&amp;quot;Ready!&amp;quot;&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;    tile0.TextBody2.Text = &lt;span style="color:#006080;"&gt;&amp;quot;Set!&amp;quot;&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;    tile0.TextBody3.Text = &lt;span style="color:#006080;"&gt;&amp;quot;Go!&amp;quot;&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;    TileNotification theTile0 = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; TileNotification(tile0.GetXml());&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;    TileUpdateManager.CreateTileUpdaterForApplication().Update(theTile0);&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;    &lt;span style="color:#008000;"&gt;//Loop and schedule required number of tiles&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;    &lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; i = 1; i &amp;lt;=val; i++)&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;    {&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;        ITileSquareBlock tile = TileContentFactory.CreateTileSquareBlock();&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;        &lt;span style="color:#008000;"&gt;//Tile main presentation is the number of current counter and will be presented to user when the tile is shown&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;        tile.TextBlock.Text = i.ToString();&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;        tile.TextSubBlock.Text = &lt;span style="color:#006080;"&gt;&amp;quot;Counting...&amp;quot;&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;        &lt;span style="color:#008000;"&gt;//Create scheduled tile notification and schedule it to run once in 5 seconds staring from now&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;        &lt;span style="color:#008000;"&gt;//Note: from my checks, it is possible to schdule the tiles once in a seconds, but some of them were skipped (about each 2-3)&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;        ScheduledTileNotification scheduledTile = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ScheduledTileNotification(tile.GetXml(), startTime.AddSeconds(i * 5));&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;        TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(scheduledTile);&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;    }&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;    &lt;span style="color:#008000;"&gt;//Create a tile with &amp;quot;All done&amp;quot; mesage&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;    ITileSquareText01 tile1 = TileContentFactory.CreateTileSquareText01();&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;    tile1.TextHeading.Text = &lt;span style="color:#006080;"&gt;&amp;quot;All Done!&amp;quot;&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;    tile1.TextBody2.Text = &lt;span style="color:#006080;"&gt;&amp;quot;Countdown stopped&amp;quot;&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;    &lt;span style="color:#008000;"&gt;//It is scheduled to run 5 seconds after last count ;)&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;    ScheduledTileNotification scheduledTile1 = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ScheduledTileNotification(tile1.GetXml(), startTime.AddSeconds((val + 1) * 5));&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:white;"&gt;    TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(scheduledTile1);&lt;/pre&gt;


    &lt;pre style="border-top-style:none;overflow:visible;font-size:8pt;border-left-style:none;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;border-bottom-style:none;color:black;padding-bottom:0px;direction:ltr;text-align:left;padding-top:0px;border-right-style:none;padding-left:0px;margin:0em;line-height:12pt;padding-right:0px;width:100%;background-color:#f4f4f4;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: In this sample I am using NotificationsExtensions – the free windows component created by Microsoft and distributed for free as a part of Windows 8 SDK samples.&lt;/p&gt;

&lt;p&gt;That’s it! Wow! So simple, but super creative! The video of my sample running (sorry for ugly UI):&lt;/p&gt;

&lt;div id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:c6ab1ae0-e398-4723-98a7-4948e4f8e451" class="wlWriterEditableSmartContent" style="float:none;padding-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;display:inline;padding-right:0px;"&gt;&lt;div&gt;&lt;object width="799" height="448"&gt;&lt;param name="movie" value="http://www.youtube.com/v/pVq4PTqEBPY?hl=en&amp;amp;hd=1"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/pVq4PTqEBPY?hl=en&amp;amp;hd=1" type="application/x-shockwave-flash" width="799" height="448"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;&lt;div style="width:799px;clear:both;font-size:.8em;"&gt;My sample running and updating live tile every ~5 seconds&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img class="wlEmoticon wlEmoticon-smile" style="border-top-style:none;border-left-style:none;border-bottom-style:none;border-right-style:none;" alt="Smile" src="http://blogs.microsoft.co.il/blogs/alex_golesh/wlEmoticon-smile_3E2470AA.png" /&gt;&lt;/p&gt;

&lt;p&gt;Clock app schedules the tiles using different tile template and points to images distributed with app. IMO it schedules 60-120 notifications, and every time background task runs adjust slightly the time and reschedules the tiles. I saw few times that the tile “skips” a minute sometime and jumps two minutes or stays on same minute instead of changing an image which makes me thing that at this time background task was running and adjusted an tiles schedule.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Enjoy and stay tuned!&lt;/p&gt;

&lt;p&gt;//Alex&lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1709389" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Csharp/default.aspx">Csharp</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows/default.aspx">Windows</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/XAML/default.aspx">XAML</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/WinRT/default.aspx">WinRT</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Live+Tile/default.aspx">Live Tile</category></item><item><title>Working with NFC–Take 2</title><link>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/10/24/working-with-nfc-take-2.aspx</link><pubDate>Wed, 24 Oct 2012 22:59:19 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1378586</guid><dc:creator>Alex Golesh</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/rsscomments.aspx?PostID=1378586</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/commentapi.aspx?PostID=1378586</wfw:comment><comments>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/10/24/working-with-nfc-take-2.aspx#comments</comments><description>&lt;p&gt;Some time ago (I’ve blogged about working with proximity devices – NFC – in Windows 8 Consumer preview: &lt;a title="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-working-with-proximity-device-part-2-11.aspx" href="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-working-with-proximity-device-part-2-11.aspx"&gt;http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-working-with-proximity-device-part-2-11.aspx&lt;/a&gt;). Then I’ve talked about a simple way performing NFC communication – using pub/sub communication pattern which is good for exchanging simple messages using PublishMessage and PublishBinaryMessage functions on ProximityDevice class.&lt;/p&gt;  &lt;p&gt;Few days ago my client asked me to prepare a demo which uses proximity communication to transfer custom “Items” between two instances of the app (and also Windows Phone 8 version of this app). The app uses complex “items” which includes many textual fields, undefined number of attached images, locations, etc. To achieve this I’ve decided to use 2nd approach to proximity communication briefly described in my previous blog post – the TriggeredConnection and Sockets. &lt;/p&gt;  &lt;p&gt;(I had additional “constraints” while engineered the solution: to minimize amount of changes in the app by using existing in-the-app load/save mechanisms and to be compatible as much as possible with Windows Phone 8 app and provide maximum code reuse between the platforms to avoid developing same functionality twice. Please keep in mind, that this blog post is not focused directly on dealing those constraints; I will blog more about sharing the code and my traditional “What’s New” series about Windows Phone 8 in a short while – so stay tuned).&lt;/p&gt;  &lt;p&gt;Let’s get started. First of all – the app must specify proximity capability in app manifest:&lt;/p&gt;  &lt;p&gt;&lt;img title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_14406C2A.png" width="375" height="602" /&gt;&lt;/p&gt;  &lt;p&gt;The app has to support two sides of proximity communication – sender and receiver. Both called peers. In both cases, I am using PeerFinder class (form Windows.Networking.Proximity namespace). In my case I’ve decided to use Triggered discovery type which supports Tap-to-Connect scenario I needed for my purposes.&lt;/p&gt;  &lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; StartConnect(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; displayName)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum2"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum3"&gt;   3:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!String.IsNullOrEmpty(displayName))&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum4"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum5"&gt;   5:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//Optionally name the peer so it could be easily identified &lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum6"&gt;   6:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//and optionally presented to user&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum7"&gt;   7:&lt;/span&gt;         PeerFinder.DisplayName = displayName;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum8"&gt;   8:&lt;/span&gt;     }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum9"&gt;   9:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum10"&gt;  10:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; ((PeerFinder.SupportedDiscoveryTypes &amp;amp; PeerDiscoveryTypes.Triggered) != PeerDiscoveryTypes.Triggered)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum11"&gt;  11:&lt;/span&gt;     {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum12"&gt;  12:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//The device doesn&amp;#39;t support tap-and-send communication&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum13"&gt;  13:&lt;/span&gt;         UpdateConnectionStatus(ConnectionStatus.NotSupported);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum14"&gt;  14:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum15"&gt;  15:&lt;/span&gt;     }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum16"&gt;  16:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum17"&gt;  17:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;//Subscribe to connection triggers&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum18"&gt;  18:&lt;/span&gt;     PeerFinder.TriggeredConnectionStateChanged += TriggeredConnectionStateChanged;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum19"&gt;  19:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum20"&gt;  20:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;//Declare alternate identities (if needed and supported)&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum21"&gt;  21:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!PeerFinder.AlternateIdentities.ContainsKey(AlternateIdentityKey))&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum22"&gt;  22:&lt;/span&gt;     {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum23"&gt;  23:&lt;/span&gt;         PeerFinder.AlternateIdentities.Add(AlternateIdentityKey, AlternateIdentity);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum24"&gt;  24:&lt;/span&gt;     }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum25"&gt;  25:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum26"&gt;  26:&lt;/span&gt;     PeerFinder.AllowInfrastructure = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum27"&gt;  27:&lt;/span&gt;     PeerFinder.AllowBluetooth = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum28"&gt;  28:&lt;/span&gt;     PeerFinder.AllowWiFiDirect = &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum29"&gt;  29:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum30"&gt;  30:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;//Start listening to proximity events&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum31"&gt;  31:&lt;/span&gt;     PeerFinder.Start();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum32"&gt;  32:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum33"&gt;  33:&lt;/span&gt;     UpdateConnectionStatus(ConnectionStatus.Ready);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum34"&gt;  34:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The code snippet above starts the connectivity. It uses enables to optionally name the peer so it could be identified by other side, checks that device support required proximity discovery mode and subscribes to connection state changes.&lt;/p&gt;

&lt;p&gt;The code above adds AlternateIdentities (see class declaration below). Alternate identities are used to enable communication between different applications and devices. As you remember, my demo requirement was to share the “items” between two instances of the app (which has same identity on all running devices) and Windows Phone 8 version of this app. Enabling the sharing between the app running Windows 8 and the app running on Windows Phone or &lt;strong&gt;different&lt;/strong&gt; app running on Windows 8 requires adding alternate identities. The actual definition of the AlternateIdentityKey in my demo looks as follows:&lt;/p&gt;

&lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color:#cc6633;"&gt;#if&lt;/span&gt; NETFX_CORE&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum2"&gt;   2:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;readonly&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; AlternateIdentityKey = &lt;span style="color:#006080;"&gt;&amp;quot;WindowsPhone&amp;quot;&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum3"&gt;   3:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;readonly&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; AlternateIdentity = &lt;span style="color:#006080;"&gt;&amp;quot;{04f1e621-039f-4829-b59f-47e71c6af98d}&amp;quot;&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum4"&gt;   4:&lt;/span&gt; &lt;span style="color:#cc6633;"&gt;#elif&lt;/span&gt; WINDOWS_PHONE&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum5"&gt;   5:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;readonly&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; AlternateIdentityKey = &lt;span style="color:#006080;"&gt;&amp;quot;Windows&amp;quot;&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum6"&gt;   6:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;readonly&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; AlternateIdentity = &lt;span style="color:#006080;"&gt;&amp;quot;a4ec8cdf-7759-4709-93af-5d2c2688ee46_cb1hhkscw5m06!App&amp;quot;&lt;/span&gt;; &lt;span style="color:#008000;"&gt;//Could be found using Windows.ApplicationModel.Package.Current.Id.FamilyName&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum7"&gt;   7:&lt;/span&gt; &lt;span style="color:#cc6633;"&gt;#endif&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This code is a part of shared code which defines AlternateIdentity for other platform and could also define the AlternateIdentity for other app running on the same platform. When compiled for Windows 8, it adds “WindowsPhone” identity key and the ID of application running on the phone; when compiled for Windows Phone 8 it adds the “Windows” identity key and the full app ID of the Windows 8 app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note&lt;/em&gt;&lt;/strong&gt;: &lt;em&gt;The app id could be obtained from app manifest (Packaging tab). 
    &lt;br /&gt;For Windows it will be the value of “Package family name” field + “!” + app ID (the namesapce and name of the App class). It also could be obtained using Windows.ApplicationModel.Package.Current.Id.FamilyName API from within the code. 

    &lt;br /&gt;For Windows Phone app it will be the value of “Product ID”.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This way PeerFinder is aware about other apps which are allowed to connect to this app. Additionally, when two devices are in proximity and the trying to establish the proximity connection, but one of the devices is not running the application (not started or in background) this alternate ID will be using by platform to identify the “target” app and pop up a toast notification asking user’s permission to start the app and establish proximity connection.&lt;/p&gt;

&lt;p&gt;When the connection is triggered, every app responds in slightly different way (depending of the app logic). In my case the TriggeredConnectionStateChanged event handler looks as follows:&lt;/p&gt;

&lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; TriggeredConnectionStateChanged(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, TriggeredConnectionStateChangedEventArgs e)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum2"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum3"&gt;   3:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;switch&lt;/span&gt; (e.State)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum4"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum5"&gt;   5:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; TriggeredConnectState.PeerFound:&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum6"&gt;   6:&lt;/span&gt;             UpdateConnectionStatus(ConnectionStatus.PeerFound);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum7"&gt;   7:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum8"&gt;   8:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; TriggeredConnectState.Connecting:&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum9"&gt;   9:&lt;/span&gt;             UpdateConnectionStatus(ConnectionStatus.Connecting);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum10"&gt;  10:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum11"&gt;  11:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; TriggeredConnectState.Listening:&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum12"&gt;  12:&lt;/span&gt;             UpdateConnectionStatus(ConnectionStatus.Listening);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum13"&gt;  13:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum14"&gt;  14:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; TriggeredConnectState.Canceled:&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum15"&gt;  15:&lt;/span&gt;             UpdateConnectionStatus(ConnectionStatus.Canceled);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum16"&gt;  16:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum17"&gt;  17:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; TriggeredConnectState.Failed:&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum18"&gt;  18:&lt;/span&gt;             UpdateConnectionStatus(ConnectionStatus.Failed);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum19"&gt;  19:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum20"&gt;  20:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; TriggeredConnectState.Completed:&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum21"&gt;  21:&lt;/span&gt;             socket = e.Socket;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum22"&gt;  22:&lt;/span&gt;             UpdateConnectionStatus(ConnectionStatus.Completed);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum23"&gt;  23:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum24"&gt;  24:&lt;/span&gt;     }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum25"&gt;  25:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;For most cases my demo just informs the user with different connectivity state changes and when connection established (Completed state) saves a Socket for future use. The main app also listens to connectivity changes and when connection is established switches to either “receive” mode or “send” mode depending on the app logic. In both cases (will show then later in the post) a socket communication will be used to send/receive raw bytes and the actual information should be first converted to bytes representation (in case of send side) and parsed back (in case of receiving side).&lt;/p&gt;

&lt;p&gt;To leverage the code we already had in the app I’ve decided to use objects serialized with JSON serializer. This also enabled me to write pretty “abstract” code which sending/receiving the items (you will see later). The next code block has two functions – GetItemStream which serializes my “item” to JSON format and ParseNewItem which deserializes received “item” from stream back to strongly typed object:&lt;/p&gt;

&lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[] GetItemStream(Item note)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum2"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum3"&gt;   3:&lt;/span&gt;     List&amp;lt;Type&amp;gt; types = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; List&amp;lt;Type&amp;gt;();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum4"&gt;   4:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;//Not required in this case, but should be used to &lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum5"&gt;   5:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;//serializing/deserializing multiple object types&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum6"&gt;   6:&lt;/span&gt;     types.Add(&lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt;(Item)); &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum7"&gt;   7:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum8"&gt;   8:&lt;/span&gt;     DataContractJsonSerializer ser = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; DataContractJsonSerializer(&lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt;(Item)&lt;span style="color:#008000;"&gt;/*, types*/&lt;/span&gt;);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum9"&gt;   9:&lt;/span&gt;     MemoryStream ms = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; MemoryStream();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum10"&gt;  10:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum11"&gt;  11:&lt;/span&gt;     ser.WriteObject(ms, note);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum12"&gt;  12:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[] json = ms.ToArray();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum13"&gt;  13:&lt;/span&gt;     var &lt;span style="color:#0000ff;"&gt;value&lt;/span&gt; = System.Text.Encoding.UTF8.GetString(json, 0, json.Length);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum14"&gt;  14:&lt;/span&gt;     Debug.WriteLine(&lt;span style="color:#006080;"&gt;&amp;quot;Serialized JSON object:\n&amp;quot;&lt;/span&gt; + &lt;span style="color:#0000ff;"&gt;value&lt;/span&gt;);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum15"&gt;  15:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; json;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum16"&gt;  16:&lt;/span&gt; }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum17"&gt;  17:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum18"&gt;  18:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; Item ParseNewItem(MemoryStream ms)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum19"&gt;  19:&lt;/span&gt; {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum20"&gt;  20:&lt;/span&gt;     List&amp;lt;Type&amp;gt; types = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; List&amp;lt;Type&amp;gt;();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum21"&gt;  21:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;//Not required in this case, but should be used to &lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum22"&gt;  22:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;//serializing/deserializing multiple object types&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum23"&gt;  23:&lt;/span&gt;     types.Add(&lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt;(Item)); &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum24"&gt;  24:&lt;/span&gt;     DataContractJsonSerializer des = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; DataContractJsonSerializer(&lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt;(Item)&lt;span style="color:#008000;"&gt;/*, types*/&lt;/span&gt;);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum25"&gt;  25:&lt;/span&gt;     var item = (Item)des.ReadObject(ms);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum26"&gt;  26:&lt;/span&gt;     item.UniqueId = DataManager.GetUniqueId();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum27"&gt;  27:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum28"&gt;  28:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; item;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum29"&gt;  29:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Once the object has been serialized and we got a stream it is ready to be sent.&lt;/p&gt;

&lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; async Task SendItemAsync([ReadOnlyArray] &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[] itemBytes, &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; imagesCount, [ReadOnlyArray] List&amp;lt;&lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[]&amp;gt; images)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum2"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum3"&gt;   3:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (itemBytes != &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; socket != &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum4"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum5"&gt;   5:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//Start sending the item&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum6"&gt;   6:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;try&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum7"&gt;   7:&lt;/span&gt;         {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum8"&gt;   8:&lt;/span&gt;             DataWriter dw = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; DataWriter(socket.OutputStream);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum9"&gt;   9:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum10"&gt;  10:&lt;/span&gt;             &lt;span style="color:#008000;"&gt;//Sending item length&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum11"&gt;  11:&lt;/span&gt;             dw.WriteInt32(itemBytes.Length);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum12"&gt;  12:&lt;/span&gt;             await dw.StoreAsync();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum13"&gt;  13:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum14"&gt;  14:&lt;/span&gt;             &lt;span style="color:#008000;"&gt;//Sending item bytes&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum15"&gt;  15:&lt;/span&gt;             dw.WriteBytes(itemBytes);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum16"&gt;  16:&lt;/span&gt;             await dw.StoreAsync();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum17"&gt;  17:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum18"&gt;  18:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt; != images &amp;amp;&amp;amp; imagesCount &amp;gt; 0) &lt;span style="color:#008000;"&gt;//The only app-specific part here...&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum19"&gt;  19:&lt;/span&gt;             {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum20"&gt;  20:&lt;/span&gt;                 &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (var imageBytes &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; images)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum21"&gt;  21:&lt;/span&gt;                 {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum22"&gt;  22:&lt;/span&gt;                     &lt;span style="color:#008000;"&gt;//Sending image length&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum23"&gt;  23:&lt;/span&gt;                     dw.WriteInt32(imageBytes.Length);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum24"&gt;  24:&lt;/span&gt;                     await dw.StoreAsync();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum25"&gt;  25:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum26"&gt;  26:&lt;/span&gt;                     &lt;span style="color:#008000;"&gt;//Sending image bytes&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum27"&gt;  27:&lt;/span&gt;                     dw.WriteBytes(imageBytes);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum28"&gt;  28:&lt;/span&gt;                     await dw.StoreAsync();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum29"&gt;  29:&lt;/span&gt;                 }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum30"&gt;  30:&lt;/span&gt;             }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum31"&gt;  31:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum32"&gt;  32:&lt;/span&gt;             &lt;span style="color:#008000;"&gt;//Flushing buffers to make sure we pushed all the data over &amp;quot;the wire&amp;quot;&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum33"&gt;  33:&lt;/span&gt;             await dw.FlushAsync();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum34"&gt;  34:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum35"&gt;  35:&lt;/span&gt;             &lt;span style="color:#008000;"&gt;//Closing DataWriter&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum36"&gt;  36:&lt;/span&gt;             dw.DetachStream();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum37"&gt;  37:&lt;/span&gt;             dw.Dispose();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum38"&gt;  38:&lt;/span&gt;         }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum39"&gt;  39:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;catch&lt;/span&gt; (Exception ex)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum40"&gt;  40:&lt;/span&gt;         {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum41"&gt;  41:&lt;/span&gt;             Debug.WriteLine(ex.Message);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum42"&gt;  42:&lt;/span&gt;             &lt;span style="color:#008000;"&gt;//Reset the connection if case of communication error&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum43"&gt;  43:&lt;/span&gt;             StopConnect();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum44"&gt;  44:&lt;/span&gt; &lt;span style="color:#cc6633;"&gt;#if&lt;/span&gt; NETFX_CORE&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum45"&gt;  45:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; PeerName = &lt;span style="color:#006080;"&gt;&amp;quot;Win8_NFC Sample&amp;quot;&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum46"&gt;  46:&lt;/span&gt; &lt;span style="color:#cc6633;"&gt;#elif&lt;/span&gt; WINDOWS_PHONE&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum47"&gt;  47:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; PeerName = &lt;span style="color:#006080;"&gt;&amp;quot;WP8_NFC Sample&amp;quot;&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum48"&gt;  48:&lt;/span&gt; &lt;span style="color:#cc6633;"&gt;#endif&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum49"&gt;  49:&lt;/span&gt;             &lt;span style="color:#008000;"&gt;//Restart connection&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum50"&gt;  50:&lt;/span&gt;             StartConnect(PeerName);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum51"&gt;  51:&lt;/span&gt;         }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum52"&gt;  52:&lt;/span&gt;     }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum53"&gt;  53:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The function is relatively simple and straight forward – user DataWriter class (System.Networking.Sockets namespace) to send bytes over socketed connection. Same goes to images which were prepared in their raw/bytes format. The code snippet which prepares and calls the SendItemAsync looks as follows (and is not shared across platforms):&lt;/p&gt;

&lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color:#008000;"&gt;//Get bytes from current item&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum2"&gt;   2:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[] bytes = ProximityManager.Instance.GetItemStream(item);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum3"&gt;   3:&lt;/span&gt; List&amp;lt;&lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[]&amp;gt; images = &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum4"&gt;   4:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum5"&gt;   5:&lt;/span&gt; &lt;span style="color:#008000;"&gt;//If item has images attached - prepare images&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum6"&gt;   6:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (item.Images.Count &amp;gt; 0)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum7"&gt;   7:&lt;/span&gt; {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum8"&gt;   8:&lt;/span&gt;     images = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; List&amp;lt;&lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[]&amp;gt;();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum9"&gt;   9:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum10"&gt;  10:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (var imgSrc &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; item.Images)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum11"&gt;  11:&lt;/span&gt;     {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum12"&gt;  12:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//Read image from local storage&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum13"&gt;  13:&lt;/span&gt;         var filename = imgSrc.Replace(&lt;span style="color:#006080;"&gt;&amp;quot;Images/&amp;quot;&lt;/span&gt;, &lt;span style="color:#006080;"&gt;&amp;quot;&amp;quot;&lt;/span&gt;);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum14"&gt;  14:&lt;/span&gt;         var storage = Windows.Storage.ApplicationData.Current.LocalFolder;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum15"&gt;  15:&lt;/span&gt;         var folder = await storage.GetFolderAsync(&lt;span style="color:#006080;"&gt;&amp;quot;Images&amp;quot;&lt;/span&gt;);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum16"&gt;  16:&lt;/span&gt;         var file = await folder.GetFileAsync(filename);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum17"&gt;  17:&lt;/span&gt;         var stream = await file.OpenReadAsync();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum18"&gt;  18:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//Prepare image bytes&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum19"&gt;  19:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[] imageBytes = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[stream.Size];&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum20"&gt;  20:&lt;/span&gt;         var str = stream.AsStream();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum21"&gt;  21:&lt;/span&gt;         await str.ReadAsync(imageBytes, 0, (&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;)stream.Size);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum22"&gt;  22:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum23"&gt;  23:&lt;/span&gt;         images.Add(imageBytes);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum24"&gt;  24:&lt;/span&gt;     }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum25"&gt;  25:&lt;/span&gt; }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum26"&gt;  26:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum27"&gt;  27:&lt;/span&gt; &lt;span style="color:#008000;"&gt;//Send the item&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum28"&gt;  28:&lt;/span&gt; await ProximityManager.Instance.SendItemAsync(bytes, item.Images.Count, images);&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The second part of the equation is to receive a message. Since we know exactly how we sending the message, the receive function looks as follows:&lt;/p&gt;

&lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; async &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; ReceiveItemAsync()&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum2"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum3"&gt;   3:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (socket != &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum4"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum5"&gt;   5:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;try&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum6"&gt;   6:&lt;/span&gt;         {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum7"&gt;   7:&lt;/span&gt;             DataReader dr = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; DataReader(socket.InputStream);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum8"&gt;   8:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum9"&gt;   9:&lt;/span&gt;             &lt;span style="color:#008000;"&gt;// Receive the size of the byte array first&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum10"&gt;  10:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (await TryLoadAsync(dr, 4))&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum11"&gt;  11:&lt;/span&gt;             {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum12"&gt;  12:&lt;/span&gt;                 var count = dr.ReadInt32();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum13"&gt;  13:&lt;/span&gt;                 &lt;span style="color:#0000ff;"&gt;uint&lt;/span&gt; ucount = (&lt;span style="color:#0000ff;"&gt;uint&lt;/span&gt;)count;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum14"&gt;  14:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum15"&gt;  15:&lt;/span&gt;                 &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (await TryLoadAsync(dr, ucount))&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum16"&gt;  16:&lt;/span&gt;                 {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum17"&gt;  17:&lt;/span&gt;                     &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[] bytesIn = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[count];&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum18"&gt;  18:&lt;/span&gt;                     dr.ReadBytes(bytesIn);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum19"&gt;  19:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum20"&gt;  20:&lt;/span&gt;                     &lt;span style="color:#008000;"&gt;//Save/parse new item&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum21"&gt;  21:&lt;/span&gt;                     MemoryStream ms = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; MemoryStream(bytesIn);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum22"&gt;  22:&lt;/span&gt;                     Item theItem = ParseNewItem(ms);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum23"&gt;  23:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum24"&gt;  24:&lt;/span&gt;                     var imagesCount = theItem.Images.Count;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum25"&gt;  25:&lt;/span&gt;                     &lt;span style="color:#008000;"&gt;//Receive &amp;quot;attached&amp;quot; images - app-specific functionality&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum26"&gt;  26:&lt;/span&gt;                     &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (imagesCount &amp;gt; 0)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum27"&gt;  27:&lt;/span&gt;                     {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum28"&gt;  28:&lt;/span&gt;                         &lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; i = 0; i &amp;lt; imagesCount; i++)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum29"&gt;  29:&lt;/span&gt;                         {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum30"&gt;  30:&lt;/span&gt;                             &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (await TryLoadAsync(dr, 4))&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum31"&gt;  31:&lt;/span&gt;                             {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum32"&gt;  32:&lt;/span&gt;                                 var imgSize = dr.ReadInt32();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum33"&gt;  33:&lt;/span&gt;                                 &lt;span style="color:#0000ff;"&gt;uint&lt;/span&gt; uimgSize = (&lt;span style="color:#0000ff;"&gt;uint&lt;/span&gt;)imgSize;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum34"&gt;  34:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum35"&gt;  35:&lt;/span&gt;                                 &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (await TryLoadAsync(dr, uimgSize))&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum36"&gt;  36:&lt;/span&gt;                                 {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum37"&gt;  37:&lt;/span&gt;                                     &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[] imgBytesIn = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[imgSize];&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum38"&gt;  38:&lt;/span&gt;                                     dr.ReadBytes(imgBytesIn);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum39"&gt;  39:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum40"&gt;  40:&lt;/span&gt;                                     MemoryStream imgMs = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; MemoryStream(imgBytesIn);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum41"&gt;  41:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum42"&gt;  42:&lt;/span&gt;                                     var imgName = theItem.Images[i];&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum43"&gt;  43:&lt;/span&gt;                                     imgName = imgName.Replace(&lt;span style="color:#006080;"&gt;&amp;quot;Images/&amp;quot;&lt;/span&gt;, &lt;span style="color:#006080;"&gt;&amp;quot;&amp;quot;&lt;/span&gt;);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum44"&gt;  44:&lt;/span&gt;                                     var fileName = await DataManager.SaveImageAsync(imgName, imgMs.AsInputStream(), Windows.Storage.CreationCollisionOption.GenerateUniqueName);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum45"&gt;  45:&lt;/span&gt;                                 }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum46"&gt;  46:&lt;/span&gt;                             }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum47"&gt;  47:&lt;/span&gt;                         }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum48"&gt;  48:&lt;/span&gt;                     }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum49"&gt;  49:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum50"&gt;  50:&lt;/span&gt;                     await DataManager.AddFileAsync(theItem);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum51"&gt;  51:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum52"&gt;  52:&lt;/span&gt;                     &lt;span style="color:#008000;"&gt;//Raise evens, so main app &amp;quot;knows&amp;quot; about new item&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum53"&gt;  53:&lt;/span&gt; &lt;span style="color:#cc6633;"&gt;#if&lt;/span&gt; NETFX_CORE&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum54"&gt;  54:&lt;/span&gt;                     await ((NFCSample.App)App.Current).Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =&amp;gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum55"&gt;  55:&lt;/span&gt; &lt;span style="color:#cc6633;"&gt;#elif&lt;/span&gt; WINDOWS_PHONE&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum56"&gt;  56:&lt;/span&gt;                     ((WP8_NFC.App)System.Windows.Application.Current).Dispatcher.BeginInvoke((Action)(() =&amp;gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum57"&gt;  57:&lt;/span&gt; &lt;span style="color:#cc6633;"&gt;#endif&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum58"&gt;  58:&lt;/span&gt;                     {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum59"&gt;  59:&lt;/span&gt;                         &lt;span style="color:#008000;"&gt;//Raise ItemReceived event&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum60"&gt;  60:&lt;/span&gt;                         &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (ItemReceived != &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum61"&gt;  61:&lt;/span&gt;                         {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum62"&gt;  62:&lt;/span&gt;                             ItemReceivedEventArgs args = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ItemReceivedEventArgs();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum63"&gt;  63:&lt;/span&gt;                             args.NewItem = theItem;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum64"&gt;  64:&lt;/span&gt;                             ItemReceived(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;, args);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum65"&gt;  65:&lt;/span&gt;                         }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum66"&gt;  66:&lt;/span&gt;                     }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum67"&gt;  67:&lt;/span&gt; &lt;span style="color:#cc6633;"&gt;#if&lt;/span&gt; WINDOWS_PHONE&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum68"&gt;  68:&lt;/span&gt;                     )&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum69"&gt;  69:&lt;/span&gt; &lt;span style="color:#cc6633;"&gt;#endif&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum70"&gt;  70:&lt;/span&gt;                     );&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum71"&gt;  71:&lt;/span&gt;                 }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum72"&gt;  72:&lt;/span&gt;             }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum73"&gt;  73:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum74"&gt;  74:&lt;/span&gt;             &lt;span style="color:#008000;"&gt;//Detach a stream and release it&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum75"&gt;  75:&lt;/span&gt;             dr.DetachStream();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum76"&gt;  76:&lt;/span&gt;             dr.Dispose();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum77"&gt;  77:&lt;/span&gt;         }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum78"&gt;  78:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;catch&lt;/span&gt; (Exception ex)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum79"&gt;  79:&lt;/span&gt;         {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum80"&gt;  80:&lt;/span&gt;             Debug.WriteLine(ex.Message);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum81"&gt;  81:&lt;/span&gt;             &lt;span style="color:#008000;"&gt;//Reset the connection in case of communication error&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum82"&gt;  82:&lt;/span&gt;             StopConnect();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum83"&gt;  83:&lt;/span&gt; &lt;span style="color:#cc6633;"&gt;#if&lt;/span&gt; NETFX_CORE&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum84"&gt;  84:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; PeerName = &lt;span style="color:#006080;"&gt;&amp;quot;Win8_NFC Sample&amp;quot;&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum85"&gt;  85:&lt;/span&gt; &lt;span style="color:#cc6633;"&gt;#elif&lt;/span&gt; WINDOWS_PHONE&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum86"&gt;  86:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; PeerName = &lt;span style="color:#006080;"&gt;&amp;quot;WP8_NFC Sample&amp;quot;&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum87"&gt;  87:&lt;/span&gt; &lt;span style="color:#cc6633;"&gt;#endif&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum88"&gt;  88:&lt;/span&gt;             &lt;span style="color:#008000;"&gt;// Restart connection&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum89"&gt;  89:&lt;/span&gt;             StartConnect(PeerName);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum90"&gt;  90:&lt;/span&gt;         }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum91"&gt;  91:&lt;/span&gt;     }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum92"&gt;  92:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;In this code I am receiving the message parts in exactly the same order as sending them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note&lt;/em&gt;&lt;/strong&gt;, &lt;em&gt;that this code is share between Windows 8 and Windows Phone 8&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Last piece of puzzle here – the helper function which reads known amount of bytes from socket:&lt;/p&gt;

&lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; async Task&amp;lt;&lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt;&amp;gt; TryLoadAsync(DataReader dr, &lt;span style="color:#0000ff;"&gt;uint&lt;/span&gt; count)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum2"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum3"&gt;   3:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;//Get cancellation token &lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum4"&gt;   4:&lt;/span&gt;     cts = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; CancellationTokenSource();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum5"&gt;   5:&lt;/span&gt;     CancellationToken token = cts.Token;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum6"&gt;   6:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum7"&gt;   7:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; result = &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum8"&gt;   8:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum9"&gt;   9:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;try&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum10"&gt;  10:&lt;/span&gt;     {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum11"&gt;  11:&lt;/span&gt;         var countReceived = await dr.LoadAsync(count).AsTask(token);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum12"&gt;  12:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum13"&gt;  13:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (countReceived != count)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum14"&gt;  14:&lt;/span&gt;         {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum15"&gt;  15:&lt;/span&gt;             &lt;span style="color:#008000;"&gt;//Connection error - close it&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum16"&gt;  16:&lt;/span&gt;             Debug.WriteLine(&lt;span style="color:#006080;"&gt;&amp;quot;Bytes read {0} != {1} total bytes. Communucation error!&amp;quot;&lt;/span&gt;, countReceived, count);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum17"&gt;  17:&lt;/span&gt;             &lt;span style="color:#008000;"&gt;//Reset connection&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum18"&gt;  18:&lt;/span&gt;             StopConnect();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum19"&gt;  19:&lt;/span&gt; &lt;span style="color:#cc6633;"&gt;#if&lt;/span&gt; NETFX_CORE&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum20"&gt;  20:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; PeerName = &lt;span style="color:#006080;"&gt;&amp;quot;Win8_NFC Sample&amp;quot;&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum21"&gt;  21:&lt;/span&gt; &lt;span style="color:#cc6633;"&gt;#elif&lt;/span&gt; WINDOWS_PHONE&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum22"&gt;  22:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; PeerName = &lt;span style="color:#006080;"&gt;&amp;quot;WP8_NFC Sample&amp;quot;&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum23"&gt;  23:&lt;/span&gt; &lt;span style="color:#cc6633;"&gt;#endif&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum24"&gt;  24:&lt;/span&gt;             &lt;span style="color:#008000;"&gt;// Restart connection&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum25"&gt;  25:&lt;/span&gt;             StartConnect(PeerName);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum26"&gt;  26:&lt;/span&gt;             result = &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum27"&gt;  27:&lt;/span&gt;         }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum28"&gt;  28:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum29"&gt;  29:&lt;/span&gt;             result = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum30"&gt;  30:&lt;/span&gt;     }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum31"&gt;  31:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;catch&lt;/span&gt; (TaskCanceledException)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum32"&gt;  32:&lt;/span&gt;     {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum33"&gt;  33:&lt;/span&gt;         result = &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum34"&gt;  34:&lt;/span&gt;     }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum35"&gt;  35:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;finally&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum36"&gt;  36:&lt;/span&gt;     {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum37"&gt;  37:&lt;/span&gt;         cts = &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum38"&gt;  38:&lt;/span&gt;     }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum39"&gt;  39:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum40"&gt;  40:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; result;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum41"&gt;  41:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This is it. Now my class is shared between two apps on multiple platforms and my samples can exchange complex custom items between instances on same and different platforms. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;To see this demo working – come to &lt;a href="http://www.buildwindows.com/" target="_blank"&gt;BUILD&lt;/a&gt; 2.0 conference taking place at Redmond, WA (October 30 - November 2, 2012) or the video I will try to film and publish after the BUILD. &lt;/p&gt;

&lt;p&gt;Also – if you are at the BUILD – feel free to find me and say “Hi”. I will be there!&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Teaser:&lt;/p&gt;

&lt;p&gt;I have a massive ‘What’s new in Windows Phone 8” series ready to be published after official release!&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Stay tuned to more posts to come. &lt;/p&gt;

&lt;p&gt;Alex&lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1378586" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows/default.aspx">Windows</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows+Phone/default.aspx">Windows Phone</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/XAML/default.aspx">XAML</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Proximity/default.aspx">Proximity</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Sockets/default.aspx">Sockets</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/wp8dev/default.aspx">wp8dev</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/NFC/default.aspx">NFC</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows+Phone+8/default.aspx">Windows Phone 8</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Communication/default.aspx">Communication</category></item><item><title>Windows 8 Release Preview</title><link>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/05/31/windows-8-release-preview.aspx</link><pubDate>Fri, 01 Jun 2012 02:18:34 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1108379</guid><dc:creator>Alex Golesh</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/rsscomments.aspx?PostID=1108379</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/commentapi.aspx?PostID=1108379</wfw:comment><comments>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/05/31/windows-8-release-preview.aspx#comments</comments><description>&lt;p&gt;Windows 8 Release Preview (RP) was published and can be downloaded by anyone who want to try this great preview of upcoming OS!&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_0FB526AD.png" width="856" height="246" /&gt;&lt;/p&gt;  &lt;p&gt;More info about it here:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://windows.microsoft.com/en-US/windows-8/release-preview" href="http://windows.microsoft.com/en-US/windows-8/release-preview"&gt;http://windows.microsoft.com/en-US/windows-8/release-preview&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Download the version to try from here:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://windows.microsoft.com/en-US/windows-8/download" href="http://windows.microsoft.com/en-US/windows-8/download"&gt;http://windows.microsoft.com/en-US/windows-8/download&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;For those, who want to grab ISO images links could be found at the following location:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://windows.microsoft.com/en-US/windows-8/iso" href="http://windows.microsoft.com/en-US/windows-8/iso"&gt;http://windows.microsoft.com/en-US/windows-8/iso&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;(this link also provides the product key to use)&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Developers, developers, developers!&lt;/strong&gt; Updated version version of Visual Studio 2012 Express RC for Windows 8 can be downloaded from the following lcoation:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://msdn.microsoft.com/en-us/windows/apps/br229516.aspx" href="http://msdn.microsoft.com/en-us/windows/apps/br229516.aspx"&gt;http://msdn.microsoft.com/en-us/windows/apps/br229516.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Aside tools you can find updated design assets, sample apps and Live SDK!&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Stay tuned for more updated to come!&lt;/p&gt;  &lt;p&gt;Alex&lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1108379" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Csharp/default.aspx">Csharp</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows/default.aspx">Windows</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/RC/default.aspx">RC</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/XAML/default.aspx">XAML</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/WinRT/default.aspx">WinRT</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/C_2B002B00_/default.aspx">C++</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/.NET+4.5/default.aspx">.NET 4.5</category></item><item><title>Windows 8 Consumer Preview and Visual Studio 11 Beta – Process Lifetime Management (Part 11/11)</title><link>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-process-lifetime-management-part-11-11.aspx</link><pubDate>Thu, 01 Mar 2012 03:46:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1023165</guid><dc:creator>Alex Golesh</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/rsscomments.aspx?PostID=1023165</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/commentapi.aspx?PostID=1023165</wfw:comment><comments>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-process-lifetime-management-part-11-11.aspx#comments</comments><description>&lt;p&gt;Windows 8 Metro applications introduces new (for desktop version of Windows) philosophy behind application execution - when application runs and when it is terminated. In this post I will overview this process also known as Process Lifetime Management (or PLM in short). In addition, I will showcase creation of custom Splash Screen experience which becomes important especially with in PLM in mind.&lt;/p&gt;
&lt;p&gt;Windows 8 designed to run not only on desktop PCs and laptops (which usually have descent amount of RAM and CPU resources), but also on tablets and low-powered PCs (with limited amount or RAM, slower CPU and usually running from battery). New Windows 8 Metro applications are full-screen applications (most of the time), meaning that for given time only one (in some scenarios, like snapping – two) application interacts with user. With this in mind, it is simply not optimal to have more than one active application; applications which are not in foreground can be “suspended”. For us, developers, the experience is like pausing application on break point in Visual Studio’s debugger: the application is alive, all memory (and thus all variables and objects) preserved, but it is not executed. Such applications keep holding memory resources but will not run any process meaning will not waste CPU resource (which leads to lower battery drain).&lt;/p&gt;
&lt;h3&gt;The application lifecycle&lt;/h3&gt;
&lt;p&gt;So what really happens? When user launches the application (I will explain the “launch” term more in depth later) it begins invocation, shows Splash Screen (as defined in application manifest) and have only 15 seconds to present a window to the user. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: If application is not capable with this requirement it will be terminated (crashed). I will overview the ways to work around this behavior in &lt;strong&gt;Custom Splash Screen&lt;/strong&gt; section.&lt;/p&gt;
&lt;p&gt;When user launches additional application, first application being moved to background – it gets “suspended” signal and have 5 seconds to save its state. After saving state application remains in-memory, but not receiving CPU allocation and other system resources. If user returns to the application it resumes immediately, since it preserved in-memory and it is just a matter of continue running from previous time (remember &lt;a href="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2010/07/14/silverlight-for-windows-phone-7-tombstoning.aspx" target="_blank"&gt;Tombstoning&lt;/a&gt; and &lt;a href="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2011/05/24/windows-phone-mango-what-s-new-fast-application-switch-fas-part-6-of-8.aspx" target="_blank"&gt;Fast Application Switch/FAS&lt;/a&gt; in Windows Phone 7?). Application gets “resuming” signal in order to restore its previous state.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: If application is not capable of finish saving state with 5 seconds from receiving “suspend” signal it will be terminated (crashed).&lt;/p&gt;
&lt;p&gt;At some point of time there will be too much applications “suspended” in memory. In low-memory devices it will happen more frequently, on powerful desktop PCs probably less frequently but also happen. In this case new application launch will cause to system look for oldest and most memory-consuming suspended application and will remove it from memory or in other words terminate the app. Since application is not running it will not get any notification about the termination.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: Application must use “suspend” signal save its state and prepare for potential termination. &lt;/p&gt;
&lt;p&gt;If user launches the terminated application again it will follow full application initialization process as it was during first launch. &lt;/p&gt;
&lt;p&gt;In order to support this behavior, application provided by &lt;font face="Courier New"&gt;Suspending&lt;/font&gt; and &lt;font face="Courier New"&gt;Resuming&lt;/font&gt; events which can be registered and handled:&lt;/p&gt;&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;public&lt;/span&gt; App()
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;this&lt;/span&gt;.InitializeComponent();
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;this&lt;/span&gt;.Resuming += App_Resuming;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;this&lt;/span&gt;.Suspending += App_Suspending;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;void&lt;/span&gt; App_Suspending(&lt;span style="COLOR:#0000ff;"&gt;object&lt;/span&gt; sender, Windows.ApplicationModel.SuspendingEventArgs e)
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    &lt;span style="COLOR:#008000;"&gt;//Get deferral opreation&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    SuspendingDeferral deferral = e.SuspendingOperation.GetDeferral();
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    &lt;span style="COLOR:#008000;"&gt;//Save state - 5 seconds only!&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;p&gt;    &lt;span style="COLOR:#008000;"&gt;//...    &lt;/span&gt;&lt;/p&gt;&lt;/pre&gt;
&lt;pre style="MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    Windows.Storage.ApplicationData.Current.LocalSettings.Values.Add(&amp;quot;SUSPENDED&amp;quot;, DateTime.Now.ToString());&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    System.Diagnostics.Debug.WriteLine(&amp;quot;&lt;span style="COLOR:#8b0000;"&gt;Suspending the app&lt;/span&gt;&amp;quot;);
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    &lt;span style="COLOR:#008000;"&gt;//Notify complete with 5 seconds - otherwise the app will be crashed&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    deferral.Complete();
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;void&lt;/span&gt; App_Resuming(&lt;span style="COLOR:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="COLOR:#0000ff;"&gt;object&lt;/span&gt; e)
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    System.Diagnostics.Debug.WriteLine(&amp;quot;&lt;span style="COLOR:#8b0000;"&gt;Resuming app&lt;/span&gt;&amp;quot;);
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    &lt;span style="COLOR:#008000;"&gt;//Reload state if resuming&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    &lt;span style="COLOR:#008000;"&gt;//...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    DateTime suspendedAt = DateTime.Parse(Windows.Storage.ApplicationData.Current.LocalSettings.Values[&amp;quot;&lt;span style="COLOR:#8b0000;"&gt;SUSPENDED&lt;/span&gt;&amp;quot;].ToString());     Windows.Storage.ApplicationData.Current.LocalSettings.Values.Remove(&amp;quot;&lt;span style="COLOR:#8b0000;"&gt;SUSPENDED&lt;/span&gt;&amp;quot;);     System.Diagnostics.Debug.WriteLine(&amp;quot;&lt;span style="COLOR:#8b0000;"&gt;Originally suspended at &lt;/span&gt;&amp;quot; + suspendedAt.ToString());
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;pre class="csharpcode"&gt;&lt;font face="Courier New"&gt;SuspendingDeferral&lt;/font&gt; is class responsible to managing suspending operation. If application has nothing to save in its state (rarely occurred), it can just safely skip getting the deferral object or simply get it and immediately report &lt;font face="Courier New"&gt;Complete&lt;/font&gt;.&lt;/pre&gt;
&lt;p&gt;To debug Suspend/Resume/Terminate behavior VS11 provides Debug Location menu, which can be added to the menus bar:&lt;/p&gt;
&lt;p&gt;&lt;img style="BACKGROUND-IMAGE:none;BORDER-RIGHT-WIDTH:0px;MARGIN:5px 5px 5px 0px;PADDING-LEFT:0px;PADDING-RIGHT:0px;DISPLAY:inline;BORDER-TOP-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-LEFT-WIDTH:0px;PADDING-TOP:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_2BD2958A.png" width="287" height="241" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="BACKGROUND-IMAGE:none;BORDER-RIGHT-WIDTH:0px;MARGIN:5px 5px 5px 0px;PADDING-LEFT:0px;PADDING-RIGHT:0px;DISPLAY:inline;BORDER-TOP-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-LEFT-WIDTH:0px;PADDING-TOP:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_4A3CD673.png" width="870" height="148" /&gt;&lt;/p&gt;
&lt;h3&gt;How application lunched?&lt;/h3&gt;
&lt;p&gt;In Windows 8 application can be executed using multiple possible actions: user taps on application’s tile on main screen (or in all applications list), invokes search with the application, shares data with application, etc. Also when launching application from main screen tile, it can be first time launch or launch after application was suspended and terminated (as described above).&amp;nbsp; To deal with this, application provided with WinRT provides number of different overrideable functions at &lt;font face="Courier New"&gt;Application&lt;/font&gt; level – &lt;font face="Courier New"&gt;OnLauched&lt;/font&gt; and &lt;font face="Courier New"&gt;OnActivated &lt;/font&gt;(and all &lt;font face="Courier New"&gt;On_XXX_Activated&lt;/font&gt;).&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;OnLaunched&lt;/font&gt; event invokes when the application is launched normally by user and provides &lt;font face="Courier New"&gt;LaunchActivatedEventArgs&lt;/font&gt; which helps to deal with different possible launch conditions (launch kind, previous execution state, arguments, etc.).&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;LauchActivatedEventArgs.Kind&lt;/font&gt; helps manage different application launch scenarios depending on how it was launched:&lt;/p&gt;
&lt;p&gt;&lt;img style="BACKGROUND-IMAGE:none;BORDER-RIGHT-WIDTH:0px;MARGIN:5px 5px 5px 0px;PADDING-LEFT:0px;PADDING-RIGHT:0px;DISPLAY:inline;BORDER-TOP-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-LEFT-WIDTH:0px;PADDING-TOP:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_03DF705E.png" width="290" height="197" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;LauchActivatedEventArgs.PreviousExecutionState&lt;/font&gt; helps to deal with situation when application was previously terminated/suspended to help create illusion of continues execution:&lt;/p&gt;
&lt;p&gt;&lt;img style="BACKGROUND-IMAGE:none;BORDER-RIGHT-WIDTH:0px;MARGIN:5px 5px 5px 0px;PADDING-LEFT:0px;PADDING-RIGHT:0px;DISPLAY:inline;BORDER-TOP-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-LEFT-WIDTH:0px;PADDING-TOP:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_62EBFDB6.png" width="313" height="120" /&gt;&lt;/p&gt;
&lt;p&gt;OnActivated (and other activated handlers like OnShareTargetActivated, OnFileActivated, OnSearchActivated, OnFileOpenPickerActivated and others) invoked when application activated either via file picker experience, share or search charm and provides relevant arguments for specific activation (like ShareOperation in case of share target activation, or search parameters in case of search activation) along with ActivationKing and PreviousExecutionState.&lt;/p&gt;
&lt;h3&gt;Custom Splash Screen&lt;/h3&gt;
&lt;p&gt;When application Activated or Launched it has only 15 seconds to present a windows. During this time system presents user with pre-defined Splash Screen. What if application needs potentially more time (for example getting data from cloud-based services)? What if application developer decides to provide some information about loading process? All those scenarios requires some custom splash screen (with potentially custom logic). But what happens with built-in one? How to deal with it?&lt;/p&gt;
&lt;p&gt;For this scenarios &lt;font face="Courier New"&gt;OnLaunched&lt;/font&gt; and &lt;font face="Courier New"&gt;OnActivated&lt;/font&gt; events provide information about &lt;font face="Courier New"&gt;SplashScreen&lt;/font&gt; which used to get information about system-managed splash screen and provide seamless alternative with custom splash screen. In my sample I created custom splash screen, which “entertains” user for some time simulating real process behind the scene.&lt;/p&gt;
&lt;p&gt;Let’s see the code. I created additional page, called ExtendedSplash which uses same image as declared in application manifest and have some additional elements to present text and waiting experience. &lt;/p&gt;
&lt;p&gt;The page initialized as follows:&lt;/p&gt;&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;private&lt;/span&gt; SplashScreen splash;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="COLOR:#0000ff;"&gt;bool&lt;/span&gt; dismissed = &lt;span style="COLOR:#0000ff;"&gt;false&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;string&lt;/span&gt; activationArgs = &lt;span style="COLOR:#0000ff;"&gt;null&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;int&lt;/span&gt; count = 0;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;string&lt;/span&gt;[] msgs = { &amp;quot;&lt;span style="COLOR:#8b0000;"&gt;Loading...&lt;/span&gt;&amp;quot;, 
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;                    &amp;quot;&lt;span style="COLOR:#8b0000;"&gt;Please wait...&lt;/span&gt;&amp;quot;, 
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;                    &amp;quot;&lt;span style="COLOR:#8b0000;"&gt;Progressing really well...&lt;/span&gt;&amp;quot;, 
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;                    &amp;quot;&lt;span style="COLOR:#8b0000;"&gt;Just few more blinks...&lt;/span&gt;&amp;quot;, 
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;                    &amp;quot;&lt;span style="COLOR:#8b0000;"&gt;Finally! Done!&lt;/span&gt;&amp;quot; };
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;span style="COLOR:#008000;"&gt;//Ctor&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;public&lt;/span&gt; ExtendedSplash(SplashScreen splashScreen, &lt;span style="COLOR:#0000ff;"&gt;bool&lt;/span&gt; dismissed, &lt;span style="COLOR:#0000ff;"&gt;string&lt;/span&gt; activationArgs)
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;this&lt;/span&gt;.InitializeComponent();
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    &lt;span style="COLOR:#008000;"&gt;//Save system copy of splash screen for future reference and activation args&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    splash = splashScreen;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;this&lt;/span&gt;.dismissed = dismissed;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;this&lt;/span&gt;.activationArgs = activationArgs;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    &lt;span style="COLOR:#008000;"&gt;//move/resize local image exactly as on system splash screen&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    extendedSplashImage.SetValue(Canvas.LeftProperty, splash.ImageLocation.X);
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    extendedSplashImage.SetValue(Canvas.TopProperty, splash.ImageLocation.Y);
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    extendedSplashImage.Height = splash.ImageLocation.Height;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    extendedSplashImage.Width = splash.ImageLocation.Width;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    &lt;span style="COLOR:#008000;"&gt;//subscribe to resize event to handle new size of splash screen while active&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    Window.Current.SizeChanged += &lt;span style="COLOR:#0000ff;"&gt;new&lt;/span&gt; WindowSizeChangedEventHandler(ExtendedSplash_OnResize);
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    &lt;span style="COLOR:#008000;"&gt;//Simulate work by running timer...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    DispatcherTimer timer = &lt;span style="COLOR:#0000ff;"&gt;new&lt;/span&gt; DispatcherTimer();
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    timer.Interval = TimeSpan.FromSeconds(1);
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    timer.Tick += (s, args) =&amp;gt;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;        count++;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;        &lt;span style="COLOR:#0000ff;"&gt;if&lt;/span&gt; (count &amp;lt; msgs.Length)
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;        {
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;            &lt;span style="COLOR:#008000;"&gt;//Present next message to user to show some progress&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;            txtMessage.Text = msgs[count];
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;        }
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;        &lt;span style="COLOR:#0000ff;"&gt;else&lt;/span&gt; &lt;span style="COLOR:#0000ff;"&gt;if&lt;/span&gt; (count &amp;gt;= msgs.Length &amp;amp;&amp;amp; &lt;span style="COLOR:#0000ff;"&gt;this&lt;/span&gt;.dismissed)
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;        {
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;            timer.Stop();
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;            timer = &lt;span style="COLOR:#0000ff;"&gt;null&lt;/span&gt;;            &lt;span style="COLOR:#008000;"&gt;// When finished, navigate to real first page&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;            var rootFrame = &lt;span style="COLOR:#0000ff;"&gt;new&lt;/span&gt; Frame();
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;            rootFrame.Navigate(&lt;span style="COLOR:#0000ff;"&gt;typeof&lt;/span&gt;(BlankPage), activationArgs.Length == 0 ? &lt;span style="COLOR:#0000ff;"&gt;null&lt;/span&gt; : activationArgs);
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;            &lt;span style="COLOR:#008000;"&gt;// Place the frame in the current Window and ensure that it is active&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;            Window.Current.Content = rootFrame;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;        }
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    };
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    timer.Start();
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    txtMessage.Text = msgs[count];
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p&gt;When screen being resized:&lt;/p&gt;&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;void&lt;/span&gt; ExtendedSplash_OnResize(Object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    &lt;span style="COLOR:#008000;"&gt;// Safely update the splash screen image coordinates&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="COLOR:#0000ff;"&gt;null&lt;/span&gt; != splash)
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;        &lt;span style="COLOR:#008000;"&gt;// Re-position the extended splash screen image due to window resize event.&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;        &lt;span style="COLOR:#0000ff;"&gt;this&lt;/span&gt;.extendedSplashImage.SetValue(Canvas.LeftProperty, splash.ImageLocation.X);
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;        &lt;span style="COLOR:#0000ff;"&gt;this&lt;/span&gt;.extendedSplashImage.SetValue(Canvas.TopProperty, splash.ImageLocation.Y);
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;        &lt;span style="COLOR:#0000ff;"&gt;this&lt;/span&gt;.extendedSplashImage.Height = splash.ImageLocation.Height;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;        &lt;span style="COLOR:#0000ff;"&gt;this&lt;/span&gt;.extendedSplashImage.Width = splash.ImageLocation.Width;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    }
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p&gt;Finally, provide event handler function, which will be used in &lt;font face="Courier New"&gt;App&lt;/font&gt; class to subscribe for system splash screen dismiss event:&lt;/p&gt;&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;internal&lt;/span&gt; &lt;span style="COLOR:#0000ff;"&gt;void&lt;/span&gt; dismissedEventHandler(Windows.ApplicationModel.Activation.SplashScreen sender, &lt;span style="COLOR:#0000ff;"&gt;object&lt;/span&gt; e)
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;this&lt;/span&gt;.dismissed = &lt;span style="COLOR:#0000ff;"&gt;true&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p&gt;In App class, redirect navigation to custom splash screen instead of real main screen:&lt;/p&gt;&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;protected&lt;/span&gt; &lt;span style="COLOR:#0000ff;"&gt;override&lt;/span&gt; &lt;span style="COLOR:#0000ff;"&gt;void&lt;/span&gt; OnLaunched(LaunchActivatedEventArgs args)
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    SplashScreen splashScreen = args.SplashScreen;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    ExtendedSplash eSplash = &lt;span style="COLOR:#0000ff;"&gt;new&lt;/span&gt; ExtendedSplash(splashScreen, &lt;span style="COLOR:#0000ff;"&gt;false&lt;/span&gt;, args.Arguments);
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    splashScreen.Dismissed += &lt;span style="COLOR:#0000ff;"&gt;new&lt;/span&gt; TypedEventHandler&amp;lt;SplashScreen, &lt;span style="COLOR:#0000ff;"&gt;object&lt;/span&gt;&amp;gt;(eSplash.dismissedEventHandler);
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    Window.Current.Content = eSplash;
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;    Window.Current.Activate();
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#ffffff;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="BACKGROUND-COLOR:#fbfbfb;MARGIN:0em;WIDTH:100%;FONT-FAMILY:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;FONT-SIZE:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p&gt;Running the app reveals seamless integration between system provided and custom splash screens:&lt;/p&gt;
&lt;p&gt;&lt;img style="BACKGROUND-IMAGE:none;BORDER-RIGHT-WIDTH:0px;MARGIN:5px 5px 5px 0px;PADDING-LEFT:0px;PADDING-RIGHT:0px;DISPLAY:inline;BORDER-TOP-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-LEFT-WIDTH:0px;PADDING-TOP:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_2D07089C.png" width="1028" height="772" /&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: In my case I decided to provided system splash screen for OnActivated experience, but same technique applies also on application activation&lt;/p&gt;
&lt;p&gt;Working extended splash screen video:&lt;/p&gt;
&lt;div style="PADDING-BOTTOM:0px;MARGIN:0px;PADDING-LEFT:0px;PADDING-RIGHT:0px;DISPLAY:inline;FLOAT:none;PADDING-TOP:0px;" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:140a75ed-9789-4c60-a540-59affa7633bd" class="wlWriterEditableSmartContent"&gt;
&lt;div&gt;
&lt;object width="691" height="387"&gt;&lt;param name="movie" value="http://www.youtube.com/v/IEFx7ugv7PM?hl=en&amp;amp;hd=1"&gt;
&lt;embed src="http://www.youtube.com/v/IEFx7ugv7PM?hl=en&amp;amp;hd=1" type="application/x-shockwave-flash" width="691" height="387"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;
&lt;div style="WIDTH:691px;CLEAR:both;FONT-SIZE:0.8em;"&gt;Custom Splash Screen&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;That’s it for now. &lt;/p&gt;
&lt;p&gt;Stay tuned for more interesting stuff to come!&lt;/p&gt;
&lt;p&gt;Alex&lt;/p&gt;&lt;pre&gt;&lt;/pre&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1023165" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Csharp/default.aspx">Csharp</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows/default.aspx">Windows</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Beta/default.aspx">Beta</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Sela/default.aspx">Sela</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/FAS/default.aspx">FAS</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Fast+Application+Switch/default.aspx">Fast Application Switch</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/XAML/default.aspx">XAML</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Consumer+Preview/default.aspx">Consumer Preview</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/PLM/default.aspx">PLM</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/WinRT/default.aspx">WinRT</category></item><item><title>Windows 8 Consumer Preview and Visual Studio 11 Beta – Live tiles, toasts, badges and Push Notifications (Part 10/11)</title><link>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-live-tiles-toasts-badges-and-push-notifications-part-10-11.aspx</link><pubDate>Thu, 01 Mar 2012 03:39:04 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1023162</guid><dc:creator>Alex Golesh</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/rsscomments.aspx?PostID=1023162</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/commentapi.aspx?PostID=1023162</wfw:comment><comments>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-live-tiles-toasts-badges-and-push-notifications-part-10-11.aspx#comments</comments><description>&lt;p&gt;Windows 8 provides interesting way to “interact” with user even when application is not active anymore. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Push Notifications&lt;/h3&gt;  &lt;p&gt;Windows Push Notifications (WNS) in Windows 8 is quite similar to the Windows Phone 7 Push Notification (MPNS) model. It uses cloud-based push notification services to deliver notifications to registered clients.&lt;/p&gt;  &lt;p&gt;To enable application receiving push notifications developer must register it at &lt;a href="https://manage.dev.live.com/build" target="_blank"&gt;Windows Push Notifications &amp;amp; Live Connect&lt;/a&gt; site. The process is very simple – developer provides Package display name and publisher found in application manifest:&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_39339872.png" width="852" height="405" /&gt;&lt;/p&gt;  &lt;p&gt;and site provides with updated package name (looks like BUILD.XXXXXXXX-XXXX-XXXX-XXXX), client secret code and package security identifier (SID, looks like ms-app://s-1-15-2-2289547533-2580522492-1560851697-4285800683-875472074-159972757-1111111111). Developer must modify package name in application manifest. Created applications can be managed &lt;a href="https://manage.dev.live.com/Applications/Index" target="_blank"&gt;Live App management&lt;/a&gt; site and retrieve information about any registered application, usage, caps, etc.&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_26126BC6.png" width="644" height="447" /&gt;&lt;/p&gt;  &lt;p&gt;After application registered and ready to receive notifications from WNS, let’s overview how the whole process works:&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_12850C25.png" width="696" height="523" /&gt;&lt;/p&gt;  &lt;p&gt;1. Metro style application uses WinRT APIs (Notification Client Platform on diagram) to open new channel to server (or reconnect with previously created channel). At the end of the process, application receives unique URI which will be used in next step.&lt;/p&gt;  &lt;p&gt;2. Any 3rd party application (Metro, classic, WPF, cloud-based service), which has URI obtained in previous step + client secret/SID combination can request Authorization token from WNS and then POST message to provided URI using received authorization token.&lt;/p&gt;  &lt;p&gt;3. 3rd party application (in my simplest case – console app) requests authorization token using client secret and SID, prepares XML payload (the message which WNS sends to client) and sends POST message to URI (from 1st step)&lt;/p&gt;  &lt;p&gt;4. WNS verifies provided information, alters Windows 8 client machine and delivers the message payload to client notification platform. Client notification platform responsible on updating tile/badge, showing toast notification, updating lock screen (if application has lock screen access) and deliver notifications to Metro app if still active.&lt;/p&gt;  &lt;p&gt;Now let’s see the application described in step 2. It has 2 main functions – GetAccessToken and Push:&lt;/p&gt;  &lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; Stream GetAccessToken(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; sid, &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; secret)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; url = &amp;quot;&lt;span style="color:#8b0000;"&gt;https://login.live.com/accesstoken.srf&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    var request = (HttpWebRequest)WebRequest.Create(url);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    request.Method = &amp;quot;&lt;span style="color:#8b0000;"&gt;POST&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    request.ContentType = &amp;quot;&lt;span style="color:#8b0000;"&gt;application/x-www-form-urlencoded&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; content = &amp;quot;&lt;span style="color:#8b0000;"&gt;grant_type=client_credentials&amp;amp;client_id={0}&amp;amp;client_secret={1}&amp;amp;scope=notify.windows.com&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; data = &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;.Format(content, sid, secret);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[] notificationMessage = Encoding.Default.GetBytes(data);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    request.ContentLength = notificationMessage.Length;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (Stream requestStream = request.GetRequestStream())
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        requestStream.Write(notificationMessage, 0, notificationMessage.Length);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    }
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    var response = (HttpWebResponse)request.GetResponse();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    Stream result = response.GetResponseStream();
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; result;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; HttpStatusCode Push(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; pushUri, &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; accessToken, &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; type, &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; notificationData)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    var subscriptionUri = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Uri(pushUri);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    var request = (HttpWebRequest)WebRequest.Create(subscriptionUri);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    request.Method = &amp;quot;&lt;span style="color:#8b0000;"&gt;POST&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    request.ContentType = &amp;quot;&lt;span style="color:#8b0000;"&gt;text/xml&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    request.Headers = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; WebHeaderCollection();
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    request.Headers.Add(&amp;quot;&lt;span style="color:#8b0000;"&gt;X-WNS-Type&lt;/span&gt;&amp;quot;, type);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    request.Headers.Add(&amp;quot;&lt;span style="color:#8b0000;"&gt;Authorization&lt;/span&gt;&amp;quot;, &amp;quot;&lt;span style="color:#8b0000;"&gt;Bearer &lt;/span&gt;&amp;quot; + accessToken);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[] notificationMessage = Encoding.Default.GetBytes(notificationData);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    request.ContentLength = notificationMessage.Length;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (Stream requestStream = request.GetRequestStream())
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        requestStream.Write(notificationMessage, 0, notificationMessage.Length);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    }
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    var response = (HttpWebResponse)request.GetResponse();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; response.StatusCode;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;The functions are pretty simple – first returns stream with Authorization token, second uses URI obtained in step 1 (see diagram) + authorization token + notification type (set as custom header, X-WNS-Type) and sends notification payload using HTTP PUSH method.&lt;/p&gt;

&lt;p&gt;The main function:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Main(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;[] args)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; pushUri = args.Length &amp;gt; 0 ? args[0] : &amp;quot;&lt;span style="color:#8b0000;"&gt;https://db3.notify.windows.com/?token=AQQAAABS%2bAYaiRtCeOtc9bhaC2xYXo7lv5A5fHEIWuDUePmnl6fxnKMf6wTMgXKp7NqSdSZ3kygzJrak%2fnGhtYV0iqJ1jIuSRJx0%2ftc6tzao1rIX2awu0p4SnYn7K5PItwKeBcY%3d&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; secret = HttpUtility.UrlEncode(&amp;quot;&lt;span style="color:#8b0000;"&gt;MY_APP_SECRET&lt;/span&gt;&amp;quot;);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; sid = HttpUtility.UrlEncode(&amp;quot;&lt;span style="color:#8b0000;"&gt;MY_APP_SID&lt;/span&gt;&amp;quot;);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    var obj = System.Json.JsonObject.Load(GetAccessToken(sid, secret));
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; accessToken = obj[&amp;quot;&lt;span style="color:#8b0000;"&gt;access_token&lt;/span&gt;&amp;quot;].ToString();
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    HttpStatusCode status;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Send Badge notification&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; badgeNotification = &amp;quot;&lt;span style="color:#8b0000;"&gt;&amp;lt;?xml version=&amp;#39;1.0&amp;#39; encoding=&amp;#39;utf-8&amp;#39;?&amp;gt;&amp;lt;badge value=\&amp;quot;2\&amp;quot;/&amp;gt;&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    status = Push(pushUri, accessToken, &amp;quot;&lt;span style="color:#8b0000;"&gt;wns/badge&lt;/span&gt;&amp;quot;, badgeNotification);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    Console.WriteLine(&amp;quot;&lt;span style="color:#8b0000;"&gt;Badge notification send reault: &lt;/span&gt;&amp;quot; + status.ToString());
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Send Toast notification&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; tostNotification = &amp;quot;&lt;span style="color:#8b0000;"&gt;&amp;lt;?xml version=&amp;#39;1.0&amp;#39; encoding=&amp;#39;utf-8&amp;#39;?&amp;gt;&amp;lt;toast&amp;gt;&amp;lt;visual&amp;gt;&amp;lt;binding template=\&amp;quot;ToastImageAndText02\&amp;quot;&amp;gt;&amp;lt;image id=\&amp;quot;1\&amp;quot; src=\&amp;quot;Images/Love.png\&amp;quot; alt=\&amp;quot;Placeholder image\&amp;quot;/&amp;gt;&amp;lt;text id=\&amp;quot;1\&amp;quot;&amp;gt;Love is in the air (PUSHED)!&amp;lt;/text&amp;gt;&amp;lt;text id=\&amp;quot;2\&amp;quot;&amp;gt;Someone sends you love waves!&amp;lt;/text&amp;gt;&amp;lt;/binding&amp;gt;&amp;lt;/visual&amp;gt;&amp;lt;/toast&amp;gt;&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    status = Push(pushUri, accessToken, &amp;quot;&lt;span style="color:#8b0000;"&gt;wns/toast&lt;/span&gt;&amp;quot;, tostNotification);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    Console.WriteLine(&amp;quot;&lt;span style="color:#8b0000;"&gt;Toast notification send reault: &lt;/span&gt;&amp;quot; + status.ToString());
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Send Tile notification&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; tileNotification = &amp;quot;&lt;span style="color:#8b0000;"&gt;&amp;lt;?xml version=&amp;#39;1.0&amp;#39; encoding=&amp;#39;utf-8&amp;#39;?&amp;gt;&amp;lt;tile&amp;gt;&amp;lt;visual&amp;gt;&amp;lt;binding template=\&amp;quot;TileWideSmallImageAndText03\&amp;quot;&amp;gt;&amp;lt;image id=\&amp;quot;1\&amp;quot; src=\&amp;quot;ms-appx:///Images/LoveInTheAir.jpg\&amp;quot;/&amp;gt;&amp;lt;text id=\&amp;quot;1\&amp;quot;&amp;gt;Someone loves you from the distance!&amp;lt;/text&amp;gt;&amp;lt;/binding&amp;gt;&amp;lt;/visual&amp;gt;&amp;lt;/tile&amp;gt;&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    status = Push(pushUri, accessToken, &amp;quot;&lt;span style="color:#8b0000;"&gt;wns/tile&lt;/span&gt;&amp;quot;,tileNotification);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    Console.WriteLine(&amp;quot;&lt;span style="color:#8b0000;"&gt;Tile notification send reault: &lt;/span&gt;&amp;quot; + status.ToString());
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    Console.WriteLine(&amp;quot;&lt;span style="color:#8b0000;"&gt;Press ENTER to exit...&lt;/span&gt;&amp;quot;);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    Console.ReadLine();
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;Also this code is pretty simple it has some important information – the notification payload XML formats. In case of Toast and Tile notification this format actually dictates which information and how it will be presented to user. To learn more about Toast/Tile formats please refer to documentation.&lt;/p&gt;

&lt;p&gt;Now when external parts are ready, let’s write Metro app functionality.&lt;/p&gt;

&lt;h3&gt;Updating tiles/toasts/badges&lt;/h3&gt;

&lt;p&gt;Tile:&lt;/p&gt;

&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_11407346.png" width="259" height="132" /&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_692DC426.png" width="132" height="133" /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: Windows 8 enables developer to provide two tiles sizes. Please refer to documentation for full templates list.&lt;/p&gt;

&lt;p&gt;Toast:&lt;/p&gt;

&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_6F0867BF.png" width="396" height="110" /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: WinRT provides multiple tile and toasts templates. Please refer to documentation for full templates list. &lt;/p&gt;

&lt;p&gt;Badges:&lt;/p&gt;

&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_78ED592A.png" width="259" height="132" /&gt;&lt;/p&gt;

&lt;p&gt;Badge notification can be either number or one of pre-defined glyphs:&lt;/p&gt;

&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_13B97F37.png" width="504" height="40" /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: The location of badge is predefined.&lt;/p&gt;

&lt;p&gt;Let’s get started with updating those items. First I will show how to open push notification channel and obtain URI:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;async Task SetupPushNotifications()
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    var pushNotificationChannel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    var channelUri = pushNotificationChannel.Uri;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    System.Diagnostics.Debug.WriteLine(channelUri); &lt;span style="color:#008000;"&gt;//This URI will be used in application described above&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Optional for my sample - not really used&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//pushNotificationChannel.PushNotificationReceived += pushNotificationChannel_PushNotificationReceived;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; pushNotificationChannel_PushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;switch&lt;/span&gt; (args.NotificationType)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; PushNotificationType.Badge:
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#008000;"&gt;//Not used in sample, but usefull to process incoming badge notification messages&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#008000;"&gt;//notificationContent = args.BadgeNotification.Content.GetXml(); &lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#008000;"&gt;//...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; PushNotificationType.Tile:
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#008000;"&gt;//Not used in sample, but usefull to process incoming tile notification messages&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#008000;"&gt;//notificationContent = args.TileNotification.Content.GetXml();&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#008000;"&gt;//...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; PushNotificationType.Toast:
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#008000;"&gt;//Not used in sample, but usefull to process incoming toast notification messages&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#008000;"&gt;//notificationContent = args.ToastNotification.Content.GetXml();&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#008000;"&gt;//...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    }
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;// prevent the notification from being delivered to the UI&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    args.Cancel = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;The code snippet creates push notification channel for main application tile and prints out received URI to debug console. I will be using this URI in app described above. Usually, application subscribes to received push notification messages using &lt;font face="Courier New"&gt;PushNotificationReceived&lt;/font&gt; event, but in my simple case I just provided the code snippet which is not really used.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: If application uses secondary tiles (additional tiles created from within application code – will be covered later in this post), it must use &lt;font face="Courier New"&gt;CreatePushNotificationChannelForSecondaryTileAsync&lt;/font&gt; method of &lt;font face="Courier New"&gt;PushNotificationChannelManager&lt;/font&gt; to get unique URI for the tile. As described above, delivered notification will be processed by client push notification platform and presented on main screen.&lt;/p&gt;

&lt;p&gt;Now let’s see how to issue an update from within the application.&lt;/p&gt;

&lt;p&gt;Generally, updating all the of tiles/badges/toasts boils down to creating correct XML according to selected template, populating values and invoking &lt;font face="Courier New"&gt;Update&lt;/font&gt; method of desired &lt;font face="Courier New"&gt;UpdaterManager&lt;/font&gt;. Example of building such XML (in this case toast notification):&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;StringBuilder builder = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; StringBuilder(&amp;quot;&lt;span style="color:#8b0000;"&gt;&amp;lt;toast&lt;/span&gt;&amp;quot;);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!String.IsNullOrEmpty(Launch))
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    builder.AppendFormat(&amp;quot;&lt;span style="color:#8b0000;"&gt; launch=&amp;#39;{0}&amp;#39;&lt;/span&gt;&amp;quot;, Util.HttpEncode(Launch));
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (Duration != ToastDuration.Short)
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    builder.AppendFormat(&amp;quot;&lt;span style="color:#8b0000;"&gt; duration=&amp;#39;{0}&amp;#39;&lt;/span&gt;&amp;quot;, Duration.ToString().ToLowerInvariant());
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;builder.Append(&amp;quot;&lt;span style="color:#8b0000;"&gt;&amp;gt;&lt;/span&gt;&amp;quot;);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;builder.AppendFormat(&amp;quot;&lt;span style="color:#8b0000;"&gt;&amp;lt;visual version=&amp;#39;{0}&amp;#39;&lt;/span&gt;&amp;quot;, Util.NOTIFICATION_CONTENT_VERSION);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!String.IsNullOrWhiteSpace(Lang))
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    builder.AppendFormat(&amp;quot;&lt;span style="color:#8b0000;"&gt; lang=&amp;#39;{0}&amp;#39;&lt;/span&gt;&amp;quot;, Util.HttpEncode(Lang));
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!String.IsNullOrWhiteSpace(BaseUri))
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    builder.AppendFormat(&amp;quot;&lt;span style="color:#8b0000;"&gt; baseUri=&amp;#39;{0}&amp;#39;&lt;/span&gt;&amp;quot;, Util.HttpEncode(BaseUri));
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;builder.Append(&amp;quot;&lt;span style="color:#8b0000;"&gt;&amp;gt;&lt;/span&gt;&amp;quot;);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;builder.AppendFormat(&amp;quot;&lt;span style="color:#8b0000;"&gt;&amp;lt;binding template=&amp;#39;{0}&amp;#39;&amp;gt;{1}&amp;lt;/binding&amp;gt;&lt;/span&gt;&amp;quot;, TemplateName, SerializeProperties(Lang, BaseUri));
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;builder.Append(&amp;quot;&lt;span style="color:#8b0000;"&gt;&amp;lt;/visual&amp;gt;&lt;/span&gt;&amp;quot;);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;AppendAudioTag(builder);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;builder.Append(&amp;quot;&lt;span style="color:#8b0000;"&gt;&amp;lt;/toast&amp;gt;&lt;/span&gt;&amp;quot;);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; builder.ToString();&lt;span style="color:#008000;"&gt;//...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; SerializeProperties(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; globalLang, &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; globalBaseUri)
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    globalLang = (globalLang != &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;) ? globalLang : String.Empty;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    globalBaseUri = String.IsNullOrWhiteSpace(globalBaseUri) ? &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt; : globalBaseUri;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    StringBuilder builder = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; StringBuilder(String.Empty);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; i = 0; i &amp;lt; m_Images.Length; i++)
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!String.IsNullOrEmpty(m_Images[i].Src))
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        {
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; escapedSrc = Util.HttpEncode(m_Images[i].Src);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!String.IsNullOrWhiteSpace(m_Images[i].Alt))
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            {
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;                &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; escapedAlt = Util.HttpEncode(m_Images[i].Alt);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;                builder.AppendFormat(&amp;quot;&lt;span style="color:#8b0000;"&gt;&amp;lt;image id=&amp;#39;{0}&amp;#39; src=&amp;#39;{1}&amp;#39; alt=&amp;#39;{2}&amp;#39;/&amp;gt;&lt;/span&gt;&amp;quot;, i + 1, escapedSrc, escapedAlt);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            }
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            {
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;                builder.AppendFormat(&amp;quot;&lt;span style="color:#8b0000;"&gt;&amp;lt;image id=&amp;#39;{0}&amp;#39; src=&amp;#39;{1}&amp;#39;/&amp;gt;&lt;/span&gt;&amp;quot;, i + 1, escapedSrc);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            }
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        }
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    }
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; i = 0; i &amp;lt; m_TextFields.Length; i++)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!String.IsNullOrWhiteSpace(m_TextFields[i].Text))
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        {
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; escapedValue = Util.HttpEncode(m_TextFields[i].Text);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!String.IsNullOrWhiteSpace(m_TextFields[i].Lang) &amp;amp;&amp;amp; !m_TextFields[i].Lang.Equals(globalLang))
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            {
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;                &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; escapedLang = Util.HttpEncode(m_TextFields[i].Lang);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;                builder.AppendFormat(&amp;quot;&lt;span style="color:#8b0000;"&gt;&amp;lt;text id=&amp;#39;{0}&amp;#39; lang=&amp;#39;{1}&amp;#39;&amp;gt;{2}&amp;lt;/text&amp;gt;&lt;/span&gt;&amp;quot;, i + 1, escapedLang, escapedValue);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            }
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            {
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;                builder.AppendFormat(&amp;quot;&lt;span style="color:#8b0000;"&gt;&amp;lt;text id=&amp;#39;{0}&amp;#39;&amp;gt;{1}&amp;lt;/text&amp;gt;&lt;/span&gt;&amp;quot;, i + 1, escapedValue);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            }
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        }
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    }
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; builder.ToString();
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;To ease on routine work, updated version of Metro samples includes reusable library named “NotificationsExtensions” which greatly simplifies this work. My sample uses this library and all the “ContentFactory” classes in code below are defined there:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#008000;"&gt;//Update badge&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;BadgeNumericNotificationContent badgeContent = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; BadgeNumericNotificationContent();
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (badgeCount &amp;gt; 0)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    badgeContent.Number = badgeCount;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification());
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#008000;"&gt;//Update application&amp;#39;s main tile&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;ITileWideSmallImageAndText03 tileContent = TileContentFactory.CreateTileWideSmallImageAndText03();
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;tileContent.TextBodyWrap.Text = message;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;tileContent.Image.Src = &amp;quot;&lt;span style="color:#8b0000;"&gt;ms-appx:///Images/&lt;/span&gt;&amp;quot; + image;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;tileContent.RequireSquareContent = &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#008000;"&gt;//Fire toast notification&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;IToastImageAndText02 templateContent = ToastContentFactory.CreateToastImageAndText02();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;templateContent.TextHeading.Text = &amp;quot;&lt;span style="color:#8b0000;"&gt;Love is in the air!&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;templateContent.TextBodyWrap.Text = message;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;templateContent.Image.Src = &amp;quot;&lt;span style="color:#8b0000;"&gt;Images/Love.png&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;templateContent.Image.Alt = &amp;quot;&lt;span style="color:#8b0000;"&gt;Placeholder image&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;IToastNotificationContent toastContent = templateContent;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;ToastNotification toast = toastContent.CreateNotification();
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;ToastNotificationManager.CreateToastNotifier().Show(toast);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;Once &lt;em&gt;XXX_&lt;/em&gt;Content populated with data this code snippet uses relevant UpdateManager to update/show relevant item. &lt;/p&gt;

&lt;h3&gt;Secondary Tiles&lt;/h3&gt;

&lt;p&gt;Updating secondary tiles:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;Uri logo = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Uri(&amp;quot;&lt;span style="color:#8b0000;"&gt;ms-appx:///images/Love.png&lt;/span&gt;&amp;quot;);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;Uri wideLogo = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Uri(&amp;quot;&lt;span style="color:#8b0000;"&gt;ms-appx:///images/WideSecondary.png&lt;/span&gt;&amp;quot;);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;SecondaryTile secondaryTile = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; SecondaryTile(&amp;quot;&lt;span style="color:#8b0000;"&gt;LoveCatcher.SecondaryTile&lt;/span&gt;&amp;quot;,
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;                                _isABoy.Value ? &amp;quot;&lt;span style="color:#8b0000;"&gt;A Boy&lt;/span&gt;&amp;quot; : &amp;quot;&lt;span style="color:#8b0000;"&gt;A Girl&lt;/span&gt;&amp;quot;,
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;                                _isABoy.Value ? &amp;quot;&lt;span style="color:#8b0000;"&gt;Lonely Boy&lt;/span&gt;&amp;quot; : &amp;quot;&lt;span style="color:#8b0000;"&gt;Lonely Girl&lt;/span&gt;&amp;quot;,
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;                                &amp;quot;&lt;span style="color:#8b0000;"&gt;pinnedID=&lt;/span&gt;&amp;quot; + (_isABoy.Value ? &amp;quot;&lt;span style="color:#8b0000;"&gt;BOY&lt;/span&gt;&amp;quot; : &amp;quot;&lt;span style="color:#8b0000;"&gt;GIRL&lt;/span&gt;&amp;quot;),
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;                                TileOptions.ShowNameOnWideLogo | TileOptions.ShowNameOnLogo,
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;                                logo,
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;                                wideLogo);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; isPinned = await secondaryTile.RequestCreateForSelectionAsync(GetElementRect(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;));
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;txtStatus.Text = isPinned ? &amp;quot;&lt;span style="color:#8b0000;"&gt;Secondary tile successfully pinned.&lt;/span&gt;&amp;quot; : &amp;quot;&lt;span style="color:#8b0000;"&gt;Secondary tile not pinned.&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;User receives request to pin secondary tile and must approve/dismiss this request. Optionally he can change tile title:&lt;/p&gt;

&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_52AAFFD2.png" width="644" height="433" /&gt;&lt;/p&gt;

&lt;p&gt;If both tiles provided (regular and wide), the user can switch between them:&lt;/p&gt;

&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_711540BB.png" width="276" height="318" /&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_5ADF2569.png" width="276" height="447" /&gt;&lt;/p&gt;

&lt;p&gt;Pinned tile arguments can be used to provide alternative loading path – more about it in next post. &lt;/p&gt;

&lt;h3&gt;Enabling lock screen access&lt;/h3&gt;

&lt;p&gt;Content published at application’s tile (tile text and badge) can be presented also when PC is locked. To enable application work under lock screen and present badge/tile, application can require user agreement by invoking the following code:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;BackgroundAccessStatus status = await BackgroundExecutionManager.RequestAccessAsync();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;switch&lt;/span&gt; (status)
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; BackgroundAccessStatus.AllowedWithRealTimeConnectivity:
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//Allowed to work under lock screen (and in background) with real-time connectivity&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; BackgroundAccessStatus.AllowedWithoutRealTimeConnectivity:
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//Allowed to work under lock screen (and in background), but without real-time connectivity&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; BackgroundAccessStatus.Denied:
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//User declined to work under lock screen &lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; BackgroundAccessStatus.Unspecified:
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//The access status not known yet. Good indication to request it&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;If access status is not defined yet, user will be presented with system message:&lt;/p&gt;

&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_397F7FCD.png" width="644" height="484" /&gt;&lt;/p&gt;

&lt;p&gt;Anytime application can request background access:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;switch&lt;/span&gt; (BackgroundExecutionManager.GetAccessStatus())
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; BackgroundAccessStatus.AllowedWithRealTimeConnectivity:
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; BackgroundAccessStatus.AllowedWithoutRealTimeConnectivity:
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; BackgroundAccessStatus.Denied:
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; BackgroundAccessStatus.Unspecified:
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;Alternatively user can add/remove supporting application using control panel:&lt;/p&gt;

&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_181FDA31.png" width="644" height="484" /&gt;&lt;/p&gt;

&lt;p&gt;Badge and tile notification shown on lock screen:&lt;/p&gt;

&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_7654019F.png" width="1027" height="772" /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: Lock screen tile notification includes only texts. If original tile notification had some graphics it will not be presented on lock screen.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Working demo:&lt;/p&gt;

&lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:04b80471-0a91-4ffc-98d3-50745ae1f9f0" class="wlWriterEditableSmartContent"&gt;&lt;div&gt;&lt;object width="664" height="372"&gt;&lt;param name="movie" value="http://www.youtube.com/v/qZumtm0caFg?hl=en&amp;amp;hd=1"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/qZumtm0caFg?hl=en&amp;amp;hd=1" type="application/x-shockwave-flash" width="664" height="372"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;&lt;div style="width:664px;clear:both;font-size:.8em;"&gt;Live tiles, toast notification and badges. Lock screen notifications&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;That’s it for now. Stay tuned to last part.&lt;/p&gt;

&lt;p&gt;Alex&lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1023162" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Csharp/default.aspx">Csharp</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows/default.aspx">Windows</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Beta/default.aspx">Beta</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Sela/default.aspx">Sela</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/XAML/default.aspx">XAML</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Consumer+Preview/default.aspx">Consumer Preview</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/WinRT/default.aspx">WinRT</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Live+Tile/default.aspx">Live Tile</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Notifications/default.aspx">Notifications</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Badge/default.aspx">Badge</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Toast/default.aspx">Toast</category></item><item><title>Windows 8 Consumer Preview and Visual Studio 11 Beta – Show Message Dialogs and Popup Menus (Part 9/11)</title><link>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-show-message-dialogs-and-popup-menus-part-9-11.aspx</link><pubDate>Thu, 01 Mar 2012 03:31:41 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1023158</guid><dc:creator>Alex Golesh</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/rsscomments.aspx?PostID=1023158</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/commentapi.aspx?PostID=1023158</wfw:comment><comments>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-show-message-dialogs-and-popup-menus-part-9-11.aspx#comments</comments><description>&lt;p&gt;This post is about popups. Why popups? Who need them?&lt;/p&gt;  &lt;p&gt;Popups needed to present some important info to the user in modal way or to present some overlays above other screen elements. &lt;/p&gt;  &lt;p&gt;Lets start from &lt;strong&gt;Message Box&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;WinRT lacks MessageBox support in classic understanding or this UI element.&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_1D4CB782.png" width="274" height="159" /&gt;&lt;/p&gt;  &lt;p&gt;While showing classic dialog box over Metro application is definitely possible from technical point of view (see screenshots in the post about In-App purchases), it completely destroys Metro look and feel of the application. For this reason WinRT provides &lt;font face="Courier New"&gt;MessageDialog&lt;/font&gt; class in &lt;font face="Courier New"&gt;Windows.UI.Popups&lt;/font&gt; namespace. This class not only enables showing popups directly over Metro application but also provides it integrated look and feel and enables customizing the dialog box buttons.&lt;/p&gt;  &lt;p&gt;Show simple dialog with one standard button (labeled “Close”), simply create a new instance of &lt;font face="Courier New"&gt;MessageDialog&lt;/font&gt; class and invoke it asynchronously:&lt;/p&gt;  &lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;Windows.UI.Popups.MessageDialog dialog = 
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;     &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Windows.UI.Popups.MessageDialog(&amp;quot;&lt;span style="color:#8b0000;"&gt;Copyright by Alex Golesh, (c) 2012&lt;/span&gt;&amp;quot;, 
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;                                         &amp;quot;&lt;span style="color:#8b0000;"&gt;Valentine Love Catcher&lt;/span&gt;&amp;quot;);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;dialog.ShowAsync();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;This code produce the following dialog:&lt;/p&gt;

&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_5C3E381D.png" width="644" height="484" /&gt;&lt;/p&gt;

&lt;p&gt;It is possible to customize the experience, and provide custom number of buttons, set default button, create custom button labels, define commands invoked on button press and get the command object after dismissing the dialog:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; async &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; btnAbout_Click(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    Windows.UI.Popups.MessageDialog dialog = 
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Windows.UI.Popups.MessageDialog(&amp;quot;&lt;span style="color:#8b0000;"&gt;Copyright by Alex Golesh, (c) 2012&lt;/span&gt;&amp;quot;, 
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;                                            &amp;quot;&lt;span style="color:#8b0000;"&gt;Valentine Love Catcher&lt;/span&gt;&amp;quot;);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Customize dialog buttons&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    dialog.Commands.Add(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; UICommand(&amp;quot;&lt;span style="color:#8b0000;"&gt;Good work!&lt;/span&gt;&amp;quot;, &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; UICommandInvokedHandler((args) =&amp;gt;{
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//Executes code on closing dialig using this command&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        loveFound = !loveFound;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    })));
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    dialog.Commands.Add(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; UICommand(&amp;quot;&lt;span style="color:#8b0000;"&gt;Thanks!&lt;/span&gt;&amp;quot;));
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    dialog.Commands.Add(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; UICommand(&amp;quot;&lt;span style="color:#8b0000;"&gt;Just close this dialog&lt;/span&gt;&amp;quot;));
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Makes &amp;quot;Thanks!&amp;quot; a default button being invoed while user press Enter key&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    dialog.DefaultCommandIndex = 1;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Returns UICommand object which makes possible to know how this dialog was dismissed&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    var dismissedBy = await dialog.ShowAsync();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    txtStatus.Text = &amp;quot;&lt;span style="color:#8b0000;"&gt;Dismissed by button labeled &amp;#39;&lt;/span&gt;&amp;quot; + dismissedBy.Label + &amp;quot;&lt;span style="color:#8b0000;"&gt;&amp;#39;&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;This code snippet produces the following message box:&lt;/p&gt;

&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_66232988.png" width="644" height="484" /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: all buttons dismiss the dialog. To wire some functionality (like asking use question providing “Yes”/”No” buttons) on dialog dismiss, use “await” syntax. ow l&lt;/p&gt;

&lt;p&gt;Now lets look at &lt;strong&gt;Context Menu&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Same namespace (&lt;font face="Courier New"&gt;Windows.UI.Popups&lt;/font&gt;) enables creating popup (formally context) menus by using new &lt;font face="Courier New"&gt;PopupMenu&lt;/font&gt; class. Working with this menu very similar to working with &lt;font face="Courier New"&gt;MessageDialog&lt;/font&gt; – the only real difference is that you cannot provide content/label texts but only &lt;font face="Courier New"&gt;UICommands&lt;/font&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; async &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; imgBoy_DoubleTapped(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, DoubleTappedRoutedEventArgs e)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    Windows.UI.Popups.PopupMenu popupMenu = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; PopupMenu();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    popupMenu.Commands.Add(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; UICommand(&amp;quot;&lt;span style="color:#8b0000;"&gt;Look for soulmate&lt;/span&gt;&amp;quot;, &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; UICommandInvokedHandler((args) =&amp;gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//Invoke some functionality&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        btnSearch_Click(sender, e);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    })));
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt; != licenseInformation)
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//Add additional commands only if user purchased some in-app products&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (licenseInformation.ProductLicenses[&amp;quot;&lt;span style="color:#8b0000;"&gt;ValentineBouquet&lt;/span&gt;&amp;quot;].IsActive || 
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            licenseInformation.ProductLicenses[&amp;quot;&lt;span style="color:#8b0000;"&gt;NewYearGift&lt;/span&gt;&amp;quot;].IsActive)
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            popupMenu.Commands.Add(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; UICommandSeparator()); &lt;span style="color:#008000;"&gt;//Create separator line&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (licenseInformation.ProductLicenses[&amp;quot;&lt;span style="color:#8b0000;"&gt;ValentineBouquet&lt;/span&gt;&amp;quot;].IsActive)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            popupMenu.Commands.Add(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; UICommand(&amp;quot;&lt;span style="color:#8b0000;"&gt;Send valentine bouquet&lt;/span&gt;&amp;quot;));
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (licenseInformation.ProductLicenses[&amp;quot;&lt;span style="color:#8b0000;"&gt;NewYearGift&lt;/span&gt;&amp;quot;].IsActive)
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            popupMenu.Commands.Add(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; UICommand(&amp;quot;&lt;span style="color:#8b0000;"&gt;Send New Year gift&lt;/span&gt;&amp;quot;));
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    }
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    var dismissedBy = await popupMenu.ShowAsync(e.GetPosition(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;));
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    txtStatus.Text = &amp;quot;&lt;span style="color:#8b0000;"&gt;Dismissed by command labeled &amp;#39;&lt;/span&gt;&amp;quot; + dismissedBy.Label + &amp;quot;&lt;span style="color:#8b0000;"&gt;&amp;#39;&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;This code snippet produces the following result:&lt;/p&gt;

&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_1DF56DAC.png" width="362" height="439" /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: like in MessageDialog, any command releases the popup menu. To wire some functionality on popup menu dismiss, use “await” syntax.&lt;/p&gt;

&lt;p&gt;This is it about the popups. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Stay tuned for the next part.&lt;/p&gt;

&lt;p&gt;Alex&lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1023158" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Csharp/default.aspx">Csharp</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows/default.aspx">Windows</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Sela/default.aspx">Sela</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/XAML/default.aspx">XAML</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Consumer+Preview/default.aspx">Consumer Preview</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Popup/default.aspx">Popup</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/WinRT/default.aspx">WinRT</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Message+Dialog/default.aspx">Message Dialog</category></item><item><title>Windows 8 Consumer Preview and Visual Studio 11 Beta – Licensing and In-app purchases (Part 7/11)</title><link>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-licensing-and-in-app-purchases-part-7-11.aspx</link><pubDate>Thu, 01 Mar 2012 03:11:48 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1023132</guid><dc:creator>Alex Golesh</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/rsscomments.aspx?PostID=1023132</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/commentapi.aspx?PostID=1023132</wfw:comment><comments>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-licensing-and-in-app-purchases-part-7-11.aspx#comments</comments><description>&lt;p&gt;Windows 8 Metro applications are distributed by Windows Store. The store handles all installation tasks, updating to the new versions when published by developer. Also it handles purchasing the application, supporting trial mode (if application developer chooses to support it) and handles in-app purchases.&lt;/p&gt;  &lt;p&gt;All licensing supported by &lt;font face="Courier New"&gt;Windows.ApplicationModel.Store&lt;/font&gt; namespace.&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_090B5B2D.png" width="437" height="163" /&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: &lt;font face="Courier New"&gt;CurrentApp&lt;/font&gt; provides license information for the current app.This object obtains its data from the Windows Store, which is not currently (Consumer Preview timeframe) supported.&lt;/p&gt;  &lt;p&gt;For development purposes we will use &lt;font face="Courier New"&gt;CurrentAppSimulator&lt;/font&gt; class, which completely mimics APIs of &lt;font face="Courier New"&gt;CurrentApp&lt;/font&gt; class but enables developing licensing support before publishing the app.&lt;/p&gt;  &lt;p&gt;Let’s see the licensing initialization code:&lt;/p&gt;  &lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; async &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; InitializeLicenseEngine()
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;#&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; DEBUG
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Point to XML infomration provoded with application instrad of getting data from Windows Store&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    await InitializeProxyFolderAsync();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    await SetupProxyFile(&amp;quot;&lt;span style="color:#8b0000;"&gt;LicenseInfo.xml&lt;/span&gt;&amp;quot;);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;#endif
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    initializeLicense();
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    UpdateCurrentLicenseMode();
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; initializeLicense()
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;#&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; DEBUG
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Use simulator for debugging&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    licenseInformation = CurrentAppSimulator.LicenseInformation;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;#&lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Use real Windows Store data&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    licenseInformation = CurrentApp.LicenseInformation;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;#endif
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Subscribe to license changes&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    licenseInformation.LicenseChanged += licenseInformation_LicenseChanged;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; licenseInformation_LicenseChanged()
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Update application logic on license changes&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    UpdateCurrentLicenseMode();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;For development purposes two helpers functions are used to provide response as it is provided by Windows Store.&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;async Task InitializeProxyFolderAsync()
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;// setup licensing proxy XML folder&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    proxyFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(&amp;quot;&lt;span style="color:#8b0000;"&gt;Microsoft\\Windows Store\\ApiData&lt;/span&gt;&amp;quot;, CreationCollisionOption.OpenIfExists);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    installLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;async Task SetupProxyFile(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; fileName)
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;// open the proxy file&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    StorageFile proxyFile = await installLocation.GetFileAsync(fileName);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;// create proxy file in application data&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    StorageFile targetFile = await proxyFolder.CreateFileAsync(&amp;quot;&lt;span style="color:#8b0000;"&gt;WindowsStoreProxy.xml&lt;/span&gt;&amp;quot;, CreationCollisionOption.ReplaceExisting);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;// replace the contents&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    await proxyFile.CopyAndReplaceAsync(targetFile);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;The XML file with all license info packed with the application to enable debugging:&lt;/p&gt;

&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_0CB4C631.png" width="289" height="563" /&gt;&lt;/p&gt;

&lt;p&gt;The file content uses same XML structure as real response from Windows Store:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;?&lt;/span&gt;xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-16&amp;quot; &lt;span style="color:#0000ff;"&gt;?&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;CurrentApp&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;ListingInformation&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;App&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;AppId&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;3C14D306-D8F8-4066-A45B-0FB3464C67F3&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;AppId&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;LinkUri&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;http://apps.microsoft.com/app/3C14D306-D8F8-4066-A45B-0FB3464C67F3&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;LinkUri&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;CurrentMarket&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;en-us&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;CurrentMarket&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;AgeRating&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;4&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;AgeRating&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;MarketData&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;xml&lt;/span&gt;:&lt;span style="color:#ff0000;"&gt;lang&lt;/span&gt;=&lt;span style="color:#0000ff;"&gt;&amp;quot;en-us&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;Valentine Love Catcher&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Description&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;Sample application to demonstrate new APIs of Windows 8&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;Description&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Price&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;5.99&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;Price&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;CurrencySymbol&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;$&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;CurrencySymbol&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;MarketData&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;App&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Product&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;ProductId&lt;/span&gt;=&lt;span style="color:#0000ff;"&gt;&amp;quot;NewYearGift&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;MarketData&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;xml&lt;/span&gt;:&lt;span style="color:#ff0000;"&gt;lang&lt;/span&gt;=&lt;span style="color:#0000ff;"&gt;&amp;quot;en-us&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;Happy 2013 New Year Gift&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Price&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;1.99&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;Price&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;CurrencySymbol&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;$&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;CurrencySymbol&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;MarketData&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;Product&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Product&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;ProductId&lt;/span&gt;=&lt;span style="color:#0000ff;"&gt;&amp;quot;ValentineBouquet&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;MarketData&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;xml&lt;/span&gt;:&lt;span style="color:#ff0000;"&gt;lang&lt;/span&gt;=&lt;span style="color:#0000ff;"&gt;&amp;quot;en-us&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;Valentine Bouquet&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Price&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;2.99&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;Price&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;CurrencySymbol&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;$&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;CurrencySymbol&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;MarketData&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;Product&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;ListingInformation&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;LicenseInformation&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;App&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;IsActive&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;true&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;IsActive&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;IsTrial&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;true&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;IsTrial&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;ExpirationDate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;2012-05-01T00:00:00.00Z&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;ExpirationDate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;App&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Product&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;ProductId&lt;/span&gt;=&lt;span style="color:#0000ff;"&gt;&amp;quot;NewYearGift&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;IsActive&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;false&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;IsActive&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;ExpirationDate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;2013-01-02T00:00:00.00Z&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;ExpirationDate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;Product&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Product&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;ProductId&lt;/span&gt;=&lt;span style="color:#0000ff;"&gt;&amp;quot;ValentineBouquet&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;IsActive&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;false&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;IsActive&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;Product&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;LicenseInformation&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;CurrentApp&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;It defines ListingInformation (product name, rating, price, etc.), in-app products (if supported) and licensing information (trial, active, expiration for application and all products).&lt;/p&gt;

&lt;p&gt;Application uses this information to adjust its functionality. In case of my sample application all the proximity functionality is disabled and changes this support when license changed:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; async &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; UpdateCurrentLicenseMode()
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Show/hide &amp;quot;Buy Now&amp;quot; button based on Trial mode&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    btnBuyNow.Visibility = licenseInformation.IsTrial ? Visibility.Visible : Visibility.Collapsed;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Check trial/active to enable/disable NFC&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (licenseInformation.IsTrial || !licenseInformation.IsActive)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//Disable proximity sensor if not active or in trial mode&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        _proximityDevice = &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//Get Windows Store (or simulator) listing info and suggest to purchase the app&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;#&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; DEBUG
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        ListingInformation listing = await CurrentAppSimulator.LoadListingInformationAsync();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;#&lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        ListingInformation listing = await CurrentApp.LoadListingInformationAsync();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;#endif
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        txtStatus.Text = &amp;quot;&lt;span style="color:#8b0000;"&gt;Proximity disabled in trial or non-licensed modes.\nPurchase this application for only &lt;/span&gt;&amp;quot; + listing.FormattedPrice;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    }
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!licenseInformation.IsTrial &amp;amp;&amp;amp; licenseInformation.IsActive &amp;amp;&amp;amp; &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt; == _proximityDevice)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//Enable proximity when application become active&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        _proximityDevice = ProximityDevice.GetDefault();
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt; != _proximityDevice)
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            txtStatus.Text = &amp;quot;&lt;span style="color:#8b0000;"&gt;Proxmity device is available and ready to go!&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    }
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Check supported in-app products to enable/disable some UI elements&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!licenseInformation.ProductLicenses[&amp;quot;&lt;span style="color:#8b0000;"&gt;ValentineBouquet&lt;/span&gt;&amp;quot;].IsActive)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        btnFlower.IsEnabled = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        btnFlower.IsEnabled = &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!licenseInformation.ProductLicenses[&amp;quot;&lt;span style="color:#8b0000;"&gt;NewYearGift&lt;/span&gt;&amp;quot;].IsActive)
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        btnBallons.IsEnabled = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        btnBallons.IsEnabled = &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;This code snippet update application’s UI and enables buying application and in-app products:&lt;/p&gt;

&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_1D4CC11F.png" width="644" height="484" /&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_5B65DBD0.png" width="644" height="484" /&gt;&lt;/p&gt;

&lt;p&gt;Pressing “Buy now” button invokes purchasing process:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; async &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; btnBuyNow_Click(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Invoke only if still in trial&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (licenseInformation.IsTrial)
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;try&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        {
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#008000;"&gt;//Purchase the application&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;#&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; DEBUG
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            await CurrentAppSimulator.RequestAppPurchaseAsync();
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;#&lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            await CurrentApp.RequestAppPurchaseAsync();
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;#endif
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#008000;"&gt;//Purchased finished successfully&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            txtStatus.Text = &amp;quot;&lt;span style="color:#8b0000;"&gt;You successfully upgraded your app to the fully-licensed version.&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        }
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;catch&lt;/span&gt; (Exception)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        {
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#008000;"&gt;//If exception thrown, provide user with information why application were not purchased&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            txtStatus.Text = &amp;quot;&lt;span style="color:#8b0000;"&gt;The upgrade transaction failed. You still have a trial license for this app.&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        }
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    }
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        txtStatus.Text = &amp;quot;&lt;span style="color:#8b0000;"&gt;You already bought this app and have a fully-licensed version.&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    }
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    UpdateCurrentLicenseMode();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;While using simulator simple dialog enables to simulate response form Windows Store to debug possible responses:&lt;/p&gt;

&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_5A2142F1.png" width="644" height="484" /&gt;&lt;/p&gt;

&lt;p&gt;Almost same process is used to purchase in-app products:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; async Task PurchaseProduct(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; ProductID)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;try&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;       &lt;span style="color:#008000;"&gt;//Start produc purchaseing&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;#&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; DEBUG
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        await CurrentAppSimulator.RequestProductPurchaseAsync(ProductID);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;#&lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        await CurrentApp.RequestProductPurchaseAsync(ProductID);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;#endif
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//Provide user some feedback about purchase success&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        ListingInformation listing = await CurrentAppSimulator.LoadListingInformationAsync();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        txtStatus.Text = &amp;quot;&lt;span style="color:#8b0000;"&gt;You successfully purchased &lt;/span&gt;&amp;quot; + listing.ProductListings[ProductID].Name + &amp;quot;&lt;span style="color:#8b0000;"&gt; for &lt;/span&gt;&amp;quot; + listing.ProductListings[ProductID].FormattedPrice;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    }
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;catch&lt;/span&gt; (Exception)
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//Handle purchase exception&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        txtStatus.Text = &amp;quot;&lt;span style="color:#8b0000;"&gt;The upgrade transaction failed. You still have a trial license for this app.&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    }
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    UpdateCurrentLicenseMode();
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;As with application purchase scenario, the simulator dialog enables to simulate response form Windows Store to debug possible responses:&lt;/p&gt;

&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_70473876.png" width="644" height="484" /&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_1F65ABE9.png" width="644" height="484" /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: since this approach uses Windows Store simulator and embedded license information the purchases are not preserved between application launches (not activations – see PLM post to understand the differences) and not synced across different user devices.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:c9900b6e-d4db-4fa3-b404-5e05cac8840b" class="wlWriterEditableSmartContent"&gt;&lt;div&gt;&lt;object width="448" height="252"&gt;&lt;param name="movie" value="http://www.youtube.com/v/WJ_yQ02xwsM?hl=en&amp;amp;hd=1"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/WJ_yQ02xwsM?hl=en&amp;amp;hd=1" type="application/x-shockwave-flash" width="448" height="252"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;&lt;div style="width:448px;clear:both;font-size:.8em;"&gt;That’s al I have to say about that © Forest Gump&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Stay tuned for next part.&lt;/p&gt;

&lt;p&gt;Alex&lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1023132" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Csharp/default.aspx">Csharp</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows/default.aspx">Windows</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Beta/default.aspx">Beta</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Sela/default.aspx">Sela</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/XAML/default.aspx">XAML</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Consumer+Preview/default.aspx">Consumer Preview</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Trial/default.aspx">Trial</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/WinRT/default.aspx">WinRT</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/License/default.aspx">License</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/In-app+purchase/default.aspx">In-app purchase</category></item><item><title>Windows 8 Consumer Preview and Visual Studio 11 Beta – Quick tip: using sensors (Part 6/11)</title><link>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-quick-tip-using-sensors-part-6-11.aspx</link><pubDate>Thu, 01 Mar 2012 02:24:16 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1023099</guid><dc:creator>Alex Golesh</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/rsscomments.aspx?PostID=1023099</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/commentapi.aspx?PostID=1023099</wfw:comment><comments>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-quick-tip-using-sensors-part-6-11.aspx#comments</comments><description>&lt;p&gt;Windows 8 supports multiple sensors. Some of them could be installed on your device, some of them not. &lt;/p&gt;  &lt;p&gt;When I planned this series, I had pretty hard choice to make about the sensor – which one to use. Accelerometer/Gyrometer/Compass/Inclinometer/Orientation are cool sensors, but their usage pretty tightly bound to specific scenarios like games (Accelerometer/Gyrometer/Inclinometer), some location aware applications (Compass) or at least orientation-aware apps (Orientation). I had to make a choice either create simple “show-the-values” boring sample or game which using those sensors (at least some of them) or showcase go with non-standard approach presenting LightSensor which was easy bound to my sample app. &lt;/p&gt;  &lt;p&gt;Since all the sensors supports same APIs, I decided to go with latter approach.&lt;/p&gt;  &lt;p&gt;Working with &lt;strong&gt;all&lt;/strong&gt; sensors are roughly the same as scenario presented in this simple post. To initialize sensor, use GetDefault function:&lt;/p&gt;  &lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#008000;"&gt;//Initialize the sensor&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;lightSensor = LightSensor.GetDefault();
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt; != lightSensor)
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Sensor is supported!&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Optionally set reporting interval. Cannot exceed hardware supported minimum reporting inteval&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    lightSensor.ReportInterval = lightSensor.MinimumReportInterval;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Subscribe to ReadingChanged event to handle new value&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    lightSensor.ReadingChanged += &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; TypedEventHandler&amp;lt;LightSensor, LightSensorReadingChangedEventArgs&amp;gt;(LightSensor_ReadingChanged);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Sensor is not supported. Use alternative app path &lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;br /&gt;

&lt;p&gt;If specific sensor supported you can optionally update &lt;font face="Courier New"&gt;ReportInterval&lt;/font&gt; property specifying how fast/slow your app requires new data. Polling new data slowly helps to preserve battery life (on battery powered devices) but can possible degrade the application functionality (especially in game scenarios when sensor, such as accelerometer, is used for main input).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: &lt;font face="Courier New"&gt;ReportInterval&lt;/font&gt; cannot be lower than hardware reported &lt;font face="Courier New"&gt;MinimumReportInterval&lt;/font&gt; provided by sensor.&lt;/p&gt;

&lt;p&gt;Working with sensor possible using two approaches – polling current reading when necessary using GetCurrentReading function:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;var currentReading = lightSensor.GetCurrentReading();&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;or provide event handler function which invoked every time sensor has a new value (like showed in first code snippet). In both cases, sensor reading object provides all relevant information (for sensor) + reading timestamp. In my sample app LightSensorReading used to change application’s background color:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; LightSensor_ReadingChanged(LightSensor sender, LightSensorReadingChangedEventArgs args)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    Dispatcher.InvokeAsync(CoreDispatcherPriority.Normal, (s, a) =&amp;gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        LightSensorReading reading = (a.Context &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; LightSensorReadingChangedEventArgs).Reading;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        LayotRoot.Background = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; SolidColorBrush(Windows.UI.Color.FromArgb(255, (&lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;)(reading.IlluminanceInLux), 0, 0));
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    }, &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;, args);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: The event handler arrives out of UI thread, so Dispatcher.InvokeAsync technique must be used to access UI elements.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;That’s in for now. Stay tuned for next post.&lt;/p&gt;

&lt;p&gt;Alex&lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1023099" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Csharp/default.aspx">Csharp</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows/default.aspx">Windows</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Beta/default.aspx">Beta</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Sela/default.aspx">Sela</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Quick+Tip/default.aspx">Quick Tip</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Senssors/default.aspx">Senssors</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/XAML/default.aspx">XAML</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Consumer+Preview/default.aspx">Consumer Preview</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Light+Sensor/default.aspx">Light Sensor</category></item><item><title>Windows 8 Consumer Preview and Visual Studio 11 Beta – Local and Roaming application data storage (Part 5/11)</title><link>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-local-and-roaming-application-data-storage-part-5-11.aspx</link><pubDate>Thu, 01 Mar 2012 02:18:51 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1023097</guid><dc:creator>Alex Golesh</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/rsscomments.aspx?PostID=1023097</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/commentapi.aspx?PostID=1023097</wfw:comment><comments>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-local-and-roaming-application-data-storage-part-5-11.aspx#comments</comments><description>&lt;p&gt;In previous post (Settings – LINK) I explained how to create application’s settings screed and customize it with application specific UI and data. In this post I will explain how to preserve application settings and other application data.&lt;/p&gt;  &lt;p&gt;Wind8 CP enables few locations to store application data. Application can use temporary directory to save any kind of information which was possible also before Windows 8. In addition WinRT provides native support saving data in application’s data store as collection of Key Value Pairs. This data can be stored locally or using roaming store. Roaming store will be synchronized by Windows if user permits data synchronization (and when such synchronization is permitted):&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_45990882.png" width="644" height="484" /&gt;&lt;/p&gt;  &lt;p&gt;To take advantage of this mechanism application must use &lt;font face="Courier New"&gt;ApplicationData&lt;/font&gt; class from &lt;font face="Courier New"&gt;Windows.Storage&lt;/font&gt; namespace. This class provides access to both, &lt;font face="Courier New"&gt;LocalSettings&lt;/font&gt; and &lt;font face="Courier New"&gt;RemoteSettings&lt;/font&gt;. Both classes exposes sample APIs, which enables abstracting Save/Load functionality from actual data location.&lt;/p&gt;  &lt;p&gt;In my sample application I am supporting both types of storages. As you probably remember from previous post, my settings screen supports switching between stores by enabling and disabling settings synchronization.&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_43C7F114.png" width="353" height="867" /&gt;&lt;/p&gt;  &lt;p&gt;Let’s get started. Regardless to actual data location (local store or cloud), application subscribes to DataChanged event. This event occurs when roaming data is synchronized (in my scenario occurs when changed on some other device running same application). &lt;/p&gt;  &lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: In my case application synchronizes only settings, then it reloads synchronized data once it was changed on other device. In other scenarios it might or might not make sense reloading synchronized data during application execution and depends exclusively on application.&lt;/p&gt;  &lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;override&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; OnNavigatedTo(NavigationEventArgs e)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{ 
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Sunbscribe to DataChanged event to get notification if data changed in some other device&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    ApplicationData.Current.DataChanged += (sender, args) =&amp;gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//Reload settings when they changes somewhere&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        ReloadSettigns();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    };
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Get settings&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    ReloadSettigns();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;Let’s see the &lt;em&gt;ReloadSettings&lt;/em&gt; function:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; ReloadSettigns()
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Application logic prefers roaming storage over local one&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    roamingSettings = ApplicationData.Current.RoamingSettings;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (roamingSettings.Values.Count == 0)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        roamingSettings = ApplicationData.Current.LocalSettings;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Application settings build from exactly 8 values. If something is missing use default values&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (roamingSettings.Values.Count == 8)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#008000;"&gt;//Value is object and must be cast to final type&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        RemotePushEnabled = (&lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt;)roamingSettings.Values[&amp;quot;&lt;span style="color:#8b0000;"&gt;RemotePushEnabled&lt;/span&gt;&amp;quot;];
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        LocationEnabled = (&lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt;)roamingSettings.Values[&amp;quot;&lt;span style="color:#8b0000;"&gt;LocationEnabled&lt;/span&gt;&amp;quot;];
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        SensorsEnabled = (&lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt;)roamingSettings.Values[&amp;quot;&lt;span style="color:#8b0000;"&gt;SensorsEnabled&lt;/span&gt;&amp;quot;];
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        LocalPushEnabled = (&lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt;)roamingSettings.Values[&amp;quot;&lt;span style="color:#8b0000;"&gt;LocalPushEnabled&lt;/span&gt;&amp;quot;];
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        SharingEnabled = (&lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt;)roamingSettings.Values[&amp;quot;&lt;span style="color:#8b0000;"&gt;SharingEnabled&lt;/span&gt;&amp;quot;];
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        ProximityEnabled = (&lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt;)roamingSettings.Values[&amp;quot;&lt;span style="color:#8b0000;"&gt;ProximityEnabled&lt;/span&gt;&amp;quot;];
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        BackgroundAccess = (&lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt;)roamingSettings.Values[&amp;quot;&lt;span style="color:#8b0000;"&gt;BackgroundAccess&lt;/span&gt;&amp;quot;];
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        SyncSettings = (&lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt;)roamingSettings.Values[&amp;quot;&lt;span style="color:#8b0000;"&gt;SyncSettings&lt;/span&gt;&amp;quot;];
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    }
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;As you remember from previous post, when some value changed on Settings screen, the value assigned to corresponding variable and &lt;em&gt;SaveSettings&lt;/em&gt; function being executed. Let’s see the function:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; SaveSettings()
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Clean previous values&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    CleanSettings();
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//If user prefers to sync data in the cloud use RoamingSettings, otherwise use LocalSettings&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (SyncSettings)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        roamingSettings = ApplicationData.Current.RoamingSettings;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        roamingSettings = ApplicationData.Current.LocalSettings;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Add values to settings&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    roamingSettings.Values.Add(&amp;quot;&lt;span style="color:#8b0000;"&gt;RemotePushEnabled&lt;/span&gt;&amp;quot;, RemotePushEnabled);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    roamingSettings.Values.Add(&amp;quot;&lt;span style="color:#8b0000;"&gt;LocationEnabled&lt;/span&gt;&amp;quot;, LocationEnabled);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    roamingSettings.Values.Add(&amp;quot;&lt;span style="color:#8b0000;"&gt;SensorsEnabled&lt;/span&gt;&amp;quot;, SensorsEnabled);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    roamingSettings.Values.Add(&amp;quot;&lt;span style="color:#8b0000;"&gt;LocalPushEnabled&lt;/span&gt;&amp;quot;, LocalPushEnabled);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    roamingSettings.Values.Add(&amp;quot;&lt;span style="color:#8b0000;"&gt;SharingEnabled&lt;/span&gt;&amp;quot;, SharingEnabled);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    roamingSettings.Values.Add(&amp;quot;&lt;span style="color:#8b0000;"&gt;ProximityEnabled&lt;/span&gt;&amp;quot;, ProximityEnabled);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    roamingSettings.Values.Add(&amp;quot;&lt;span style="color:#8b0000;"&gt;BackgroundAccess&lt;/span&gt;&amp;quot;, BackgroundAccess);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    roamingSettings.Values.Add(&amp;quot;&lt;span style="color:#8b0000;"&gt;SyncSettings&lt;/span&gt;&amp;quot;, SyncSettings);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Signal data changed which will trigger cloud sync process when system synchronizes data next time&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    ApplicationData.Current.SignalDataChanged();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; CleanSettings()
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt; != roamingSettings)
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        roamingSettings.Values.Clear();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: Cleaning all values instead of replacing them is probably not the best practice which can increase synchronization traffic usage, but in case of such simple example (and for code brevity) I preferred this approach.&lt;/p&gt;

&lt;p&gt;In addition settings can be organized in Containers:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#008000;"&gt;//Create new container&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;roamingSettings.CreateContainer(&amp;quot;&lt;span style="color:#8b0000;"&gt;GeneralSettings&lt;/span&gt;&amp;quot;, ApplicationDataCreateDisposition.Always);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#008000;"&gt;//Setting named value in specific container&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;roamingSettings.Containers[&amp;quot;&lt;span style="color:#8b0000;"&gt;GeneralSettings&lt;/span&gt;&amp;quot;].Values.Add(&amp;quot;&lt;span style="color:#8b0000;"&gt;RegisteredUser&lt;/span&gt;&amp;quot;, &amp;quot;&lt;span style="color:#8b0000;"&gt;AlexG&lt;/span&gt;&amp;quot;);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#008000;"&gt;//Getting named value form specific container&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; user = (&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;)roamingSettings.Containers[&amp;quot;&lt;span style="color:#8b0000;"&gt;GeneralSettings&lt;/span&gt;&amp;quot;].Values[&amp;quot;&lt;span style="color:#8b0000;"&gt;RegisteredUser&lt;/span&gt;&amp;quot;];
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#008000;"&gt;//Delete container with all values&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;roamingSettings.DeleteContainer(&amp;quot;&lt;span style="color:#8b0000;"&gt;GeneralSettings&lt;/span&gt;&amp;quot;);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;When using roaming settings important to know how much data being synced and how much could be synced. ApplicationData class provides information about roaming storage quota and usage:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;ulong&lt;/span&gt; quota = ApplicationData.Current.RoamingStorageQuota;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;ulong&lt;/span&gt; used = ApplicationData.Current.RoamingStorageUsage;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;In addition, it is possible to create basic version management of data stored in any store by querying current version and setting new version:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#008000;"&gt;//Get current version&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;uint&lt;/span&gt; version = ApplicationData.Current.Version;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#008000;"&gt;//Set new version&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;await ApplicationData.Current.SetVersionAsync(123, &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ApplicationDataSetVersionHandler((version) =&amp;gt; {
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (version.CurrentVersion == version.DesiredVersion)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;         &lt;span style="color:#008000;"&gt;//Worked&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    }
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    {
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;         &lt;span style="color:#008000;"&gt;//Something went wrong...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    }
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}));
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;Last, but not least, ApplicationData class provides access to Local/Roaming/Temporary folders. All classes exposes the sample API and enables managing files and folders using standard WinRT async patterns:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#008000;"&gt;//Create file in roaming folder. Also possible to create file/folder in ApplicationData.Current.TemporaryFolder or ApplicationData.Current.LocalFolder&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;StorageFile file = await ApplicationData.Current.RoamingFolder.CreateFileAsync(&amp;quot;&lt;span style="color:#8b0000;"&gt;settings.dat&lt;/span&gt;&amp;quot;, CreationCollisionOption.ReplaceExisting);&lt;span style="color:#008000;"&gt;//Open file for writing and write some binary buffer...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;Stream stream = await file.OpenStreamForWriteAsync();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;stream.Write(buffer, offset, count);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;await stream.FlushAsync();
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;That’s it for now. &lt;/p&gt;

&lt;p&gt;Stay tuned for next part.&lt;/p&gt;

&lt;p&gt;Alex&lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1023097" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Csharp/default.aspx">Csharp</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows/default.aspx">Windows</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Beta/default.aspx">Beta</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Sela/default.aspx">Sela</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/XAML/default.aspx">XAML</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Consumer+Preview/default.aspx">Consumer Preview</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Settings/default.aspx">Settings</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/WinRT/default.aspx">WinRT</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Roaming/default.aspx">Roaming</category></item><item><title>Windows 8 Consumer Preview and Visual dStudio 11 Beta – Customizing Settings Charm (Part 4/11)</title><link>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-dstudio-11-beta-customizing-settings-charm-part-4-11.aspx</link><pubDate>Thu, 01 Mar 2012 02:04:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1023090</guid><dc:creator>Alex Golesh</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/rsscomments.aspx?PostID=1023090</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/commentapi.aspx?PostID=1023090</wfw:comment><comments>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-dstudio-11-beta-customizing-settings-charm-part-4-11.aspx#comments</comments><description>&lt;p&gt;Before Windows 8 every application invented its own way to present application settings. Here are very few of them:&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_7EEDED02.png" width="362" height="484" /&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_6CDD9576.png" width="641" height="484" /&gt;&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_1039EE42.png" width="644" height="411" /&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_3A59765D.png" width="440" height="484" /&gt;&lt;/p&gt;  &lt;p&gt;Some apps even provided standalone applications to manage settings. Also from settings storage perspective every developer had to decide when, where and how those settings are saved and in some cases synchronized between different user’s machines.&lt;/p&gt;  &lt;p&gt;With Windows 8 Metro applications most of those questions and hard choices are gone. Every Metro application can use system-wide standard way to present settings and collect them in predictable and system-standard way. Windows 8 provides “Settings” charm which is accessible as a part of system menu.&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_4A790259.png" width="93" height="692" /&gt;&lt;/p&gt;  &lt;p&gt;By default, if not customized, application will have only one (system provisioned) settings entry – Permissions.This menu item shows basic application package information and special permissions application uses (as provided by application manifest)&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_16D095FB.png" width="350" height="867" /&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_24DF5F2B.png" width="348" height="867" /&gt;&lt;/p&gt;  &lt;p&gt;Application developer can customize the contents of Settings charm by adding custom menu entries (commands) and handling it in application.&lt;/p&gt;  &lt;p&gt;When user opens the settings charm application gets a chance to provide custom commands. To get notified about this request subscribe to &lt;font face="Courier New"&gt;CommandsRequested&lt;/font&gt; event of &lt;font face="Courier New"&gt;SettingsPane&lt;/font&gt; class as in the following code snippet:&lt;/p&gt;  &lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#008000;"&gt;//Setup settings panel&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;Application can provide customized UI to launch the settings charm. To show this charm invoke the following code as response your application corresponding UI request:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;SettingsPane.Show();&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;Once user invokes this functionality or opens Settings charm by system gesture &lt;font face="Courier New"&gt;OnCommandsRequested&lt;/font&gt; handler being executed. In order to add new item (Command) to settings pane you have to create new instance of &lt;font face="Courier New"&gt;SettignsCommand&lt;/font&gt; class providing CommandId, Label and handler function (which will be executed in user invokes the command):&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; BlankPage_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    SettingsCommand SyncSettingsCommand = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; SettingsCommand(&amp;quot;&lt;span style="color:#8b0000;"&gt;SyncSettings&lt;/span&gt;&amp;quot;, SyncSettings ? &amp;quot;&lt;span style="color:#8b0000;"&gt;Disable settings sync&lt;/span&gt;&amp;quot; : &amp;quot;&lt;span style="color:#8b0000;"&gt;Enable settings sync&lt;/span&gt;&amp;quot;, &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; UICommandInvokedHandler(onSettingsSync));
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    args.Request.ApplicationCommands.Add(SyncSettingsCommand);
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    SettingsCommand helpCommand = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; SettingsCommand(&amp;quot;&lt;span style="color:#8b0000;"&gt;HelpPage&lt;/span&gt;&amp;quot;, &amp;quot;&lt;span style="color:#8b0000;"&gt;Help&lt;/span&gt;&amp;quot;, &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; UICommandInvokedHandler(onHelpCommand));
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    args.Request.ApplicationCommands.Add(helpCommand);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; onSettingsSync(IUICommand command)
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Do application logic for setting change&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    SyncSettings = !SyncSettings;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    SaveSettings();
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; onHelpCommand(IUICommand command)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    helpPage.Margin = ThicknessHelper.FromUniformLength(0);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: Most of the commands were skipped for brevity of the code. &lt;font face="Courier New"&gt;SaveSettigs&lt;/font&gt; functionality will be discussed in my next post.&lt;/p&gt;

&lt;p&gt;Customized settings charm (permissions are provided by OS):&lt;/p&gt;

&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_5DA9932B.png" width="352" height="868" /&gt;&lt;/p&gt;

&lt;p&gt;Let us see two typical settings commands: direct value change (like Sync settings) and “link” to some additional settings screen. In both cases, taping (clicking) the command on settings charm dismisses the charm. While in case of Sync settings the command is responsible for direct change of the setting, in case of Help we want to present some additional functionality and screen. Unfortunately it is not possible to integrate custom user control into settings charm, so application developer must provide the UI and system-like behavior.&lt;/p&gt;

&lt;p&gt;System-like behavior assumes that changes made in custom panel are implemented/saved as they done, panel enables navigating back to system settings pane and supports light dismiss – clicking anywhere else of the panel dismisses the panel and saves the settings.&lt;/p&gt;

&lt;p&gt;In my application I created simple user control, which were initially placed off main screen (using negative margin):&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#c71585;"&gt;local&lt;/span&gt;:&lt;span style="color:#800000;"&gt;HelpPage&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;x&lt;/span&gt;:&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000ff;"&gt;&amp;quot;helpPage&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;Margin&lt;/span&gt;=&lt;span style="color:#0000ff;"&gt;&amp;quot;0,0,-346,0&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;HorizontalAlignment&lt;/span&gt;=&lt;span style="color:#0000ff;"&gt;&amp;quot;Right&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#c71585;"&gt;local&lt;/span&gt;:&lt;span style="color:#800000;"&gt;HelpPage.Transitions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;TransitionCollection&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;            &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;RepositionThemeTransition&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;TransitionCollection&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#c71585;"&gt;local&lt;/span&gt;:&lt;span style="color:#800000;"&gt;HelpPage.Transitions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#c71585;"&gt;local&lt;/span&gt;:&lt;span style="color:#800000;"&gt;HelpPage&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;br /&gt;

&lt;p&gt;I defined transition effect for my custom control to enable repositioning using system-like animation (&lt;font face="Courier New"&gt;RepositionThemeTransition&lt;/font&gt;). Using this effect helps mimic “sliding out” effect like real system-provided settings charm does. Final custom settings panel looks like the following:&lt;/p&gt;

&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_7ADB4D03.png" width="353" height="868" /&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_05F4B181.png" width="352" height="867" /&gt;&lt;/p&gt;

&lt;p&gt;To support light-dismiss I’ve subscribed to &lt;font face="Courier New"&gt;PointerPressed&lt;/font&gt; event on parent UI element (in my case – Grid):&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Grid&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;PointerPressed&lt;/span&gt;=&lt;span style="color:#0000ff;"&gt;&amp;quot;Grid_PointerPressed&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;And in handler function simply changed the &lt;font face="Courier New"&gt;Margin&lt;/font&gt; property of the control:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Grid_PointerPressed(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, Windows.UI.Xaml.Input.PointerEventArgs e)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Change margin only if control is visible&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (helpPage.Margin.Right == 0)
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;        helpPage.Margin = ThicknessHelper.FromLengths(0, 0, -346, 0);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;At the control level, I subscribed to back button &lt;font face="Courier New"&gt;Click&lt;/font&gt; event:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Button&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;x&lt;/span&gt;:&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000ff;"&gt;&amp;quot;backButton&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;Click&lt;/span&gt;=&lt;span style="color:#0000ff;"&gt;&amp;quot;GoBack&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;Style&lt;/span&gt;=&lt;span style="color:#0000ff;"&gt;&amp;quot;{StaticResource BackButtonStyle}&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;Margin&lt;/span&gt;=&lt;span style="color:#0000ff;"&gt;&amp;quot;0&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;and in event handler I re-opened settings pane and hided the panel:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; GoBack(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Reopen settings pane&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    SettingsPane.Show();
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//Hide this panel&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.Margin = ThicknessHelper.FromLengths(0, 0, -346, 0);
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;Small trick here – you control must subscribe and handle &lt;font face="Courier New"&gt;PointerPressed&lt;/font&gt; event, otherwise parent control (Grid in my case) will dismiss it on any tap/click, even on control itself:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; UserControl_PointerPressed(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, PointerEventArgs e)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    e.Handled = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;The control logic (the rest of code you have to write) is absolutely unique for each application.&lt;/p&gt;

&lt;p&gt;The working settings pane with custom help panel demonstrated here:&lt;/p&gt;

&lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:0b8f63a0-d60d-4960-96d2-376e6676facf" class="wlWriterEditableSmartContent"&gt;&lt;div&gt;&lt;object width="737" height="413"&gt;&lt;param name="movie" value="http://www.youtube.com/v/pYyFoMpKwhg?hl=en&amp;amp;hd=1"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/pYyFoMpKwhg?hl=en&amp;amp;hd=1" type="application/x-shockwave-flash" width="737" height="413"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;&lt;div style="width:737px;clear:both;font-size:.8em;"&gt;Integrating custom panel in settings panel&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Using the techniques described above you application supports standard Windows 8 settings behaviour.&lt;/p&gt;

&lt;p&gt;That’s it for now.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Stay tuned for next post.&lt;/p&gt;

&lt;p&gt;Alex&lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1023090" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Csharp/default.aspx">Csharp</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows/default.aspx">Windows</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Beta/default.aspx">Beta</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Sela/default.aspx">Sela</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/XAML/default.aspx">XAML</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Consumer+Preview/default.aspx">Consumer Preview</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Settings/default.aspx">Settings</category></item><item><title>Windows 8 Consumer Preview and Visual Studio 11 Beta – Working with Proximity Device (Part 2/11)</title><link>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-working-with-proximity-device-part-2-11.aspx</link><pubDate>Thu, 01 Mar 2012 01:50:18 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1023079</guid><dc:creator>Alex Golesh</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/rsscomments.aspx?PostID=1023079</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/commentapi.aspx?PostID=1023079</wfw:comment><comments>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-working-with-proximity-device-part-2-11.aspx#comments</comments><description>&lt;p&gt;This post is about proximity devices and scenarios enabled by using this functionality.&lt;/p&gt;  &lt;p&gt;WinRT supports Near Field Communication (NFC) scenarios by providing native support using &lt;font face="Courier New"&gt;Windows.Networking.Proximity&lt;/font&gt; namespace. This namespace enable working with proximity device in two different modes – direct communication using sockets (&lt;font face="Courier New"&gt;ProximityStreamSocket&lt;/font&gt; class) and publish/subscribe mode (using &lt;font face="Courier New"&gt;ProximityMessage&lt;/font&gt; class). &lt;font face="Courier New"&gt;ProximityDevice&lt;/font&gt; class provides gateway to hardware NFC device component (if present in computer/tablet, drivers are installed and user permits using such type of devices). &lt;/p&gt;  &lt;p&gt;To use Proximity device it must be manifested in Capabilities section of application manifest:&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_14406C2A.png" width="375" height="602" /&gt;&lt;/p&gt;  &lt;p&gt;In both cases first you need to acquire the proximity device:&lt;/p&gt; 




.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }  &lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;ProximityDevice _proximityDevice;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;_proximityDevice = ProximityDevice.GetDefault();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;//Check for proximity device presence&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt; == _proximityDevice)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;{&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#008000;"&gt;//Device is not present or not enabled. Have a &amp;quot;backup&amp;quot; plan&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#008000;"&gt;//...&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;}&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;{&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#008000;"&gt;//Device is presend and working&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#008000;"&gt;//...&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Using sockets requires using &lt;font face="Courier New"&gt;PeerFinder&lt;/font&gt; class which helps looking for devices, enables getting requests from arriving device and connection to them. Once two peers completer the connection cycle (PeerFinder.TriggeredConnectionState == &lt;font face="Courier New"&gt;TriggeredConnectState.Completed&lt;/font&gt;) event arguments provides an instance of &lt;font face="Courier New"&gt;ProximitryStreamSocket&lt;/font&gt; class which is used to transmit data between devices.&lt;/p&gt;

&lt;p&gt;While this technique is relatively advanced and requires subscribing to multiple events and managing socketed connection, ProximityDevice class provides easier way to transmit messages between two PCs/Tablets. Using pub/sub model requires subscribing to known message type from one hand and publishing known message type from other hand. Once connection established and message delivered devices can stop publishing/listening to the messages:&lt;/p&gt;

&lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;long&lt;/span&gt; _subscribedMessageId = -1;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;long&lt;/span&gt; _publishedMessageId = -1;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;//...&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;//-----------------------------------------------------------------------------------------&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;//Subscribing to messages&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (_subscribedMessageId == -1)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;{&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#008000;"&gt;//Start listening for messages&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    _subscribedMessageId = _proximityDevice.SubscribeForMessage(&lt;span style="color:#006080;"&gt;&amp;quot;Windows.TheLoveMessage&amp;quot;&lt;/span&gt;, (_proximityDevice, message) =&amp;gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;        &lt;span style="color:#008000;"&gt;//When message arrives proceed with application logic&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;        &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (message.DataAsString.Contains(&lt;span style="color:#006080;"&gt;&amp;quot;LOVE;&amp;quot;&lt;/span&gt;))&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;        {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;            &lt;span style="color:#008000;"&gt;///...&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;        }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;        &lt;span style="color:#008000;"&gt;//Optionally, stop listening to messgaes if applicaton logic requires so&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;        _proximityDevice.StopSubscribingForMessage(_subscribedMessageId);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    });&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;}&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#008000;"&gt;//Already subscribed to message...&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;//...&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;//-----------------------------------------------------------------------------------------&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;//Publish messages&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (_publishedMessageId == -1)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;{&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#008000;"&gt;//Start publishing messages&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    _publishedMessageId = _proximityDevice.PublishMessage(&lt;span style="color:#006080;"&gt;&amp;quot;Windows.TheLoveMessage&amp;quot;&lt;/span&gt;, &lt;span style="color:#006080;"&gt;&amp;quot;LOVE;&amp;quot;&lt;/span&gt; + txtName.Text);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#008000;"&gt;//The rest of applciation logic after starting publishing the message&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;}&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#008000;"&gt;//Already publishing the message...&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;//...&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;//-----------------------------------------------------------------------------------------&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;//When not needed anymore, stop publishing the message&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;_proximityDevice.StopPublishingMessage(_publishedMessageId);&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;In addition, &lt;font face="Courier New"&gt;ProximityDevice&lt;/font&gt; enables subscribing to &lt;font face="Courier New"&gt;DeviceArrived&lt;/font&gt; and &lt;font face="Courier New"&gt;DeviceDeparted&lt;/font&gt; events, which helps to maintain state of connected/disconnected devices and provides information about them:&lt;/p&gt;

&lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;//Get proximity device&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;_proximityDevice = ProximityDevice.GetDefault();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;//If device initialized successfully&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt; != _proximityDevice)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;{&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#008000;"&gt;//Subscribe to DeviceArrived event&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    _proximityDevice.DeviceArrived += (arrivedProximityDevice) =&amp;gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;        {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;            &lt;span style="color:#008000;"&gt;//...&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;        };&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#008000;"&gt;//Subscribe to DeviceADeparted event&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    _proximityDevice.DeviceDeparted += (departedProximityDevice) =&amp;gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;        {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;            &lt;span style="color:#008000;"&gt;//...&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;        };&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: &lt;font face="Courier New"&gt;MessageType&lt;/font&gt; parameter in &lt;font face="Courier New"&gt;PublishMessage&lt;/font&gt; function must begin from “&lt;font face="Courier New"&gt;Windows.&lt;/font&gt;”&lt;/p&gt;

&lt;p&gt;That’s it for now. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Stay tuned for next part.&lt;/p&gt;

&lt;p&gt;Alex&lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1023079" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows/default.aspx">Windows</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Beta/default.aspx">Beta</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Sela/default.aspx">Sela</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/XAML/default.aspx">XAML</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Consumer+Preview/default.aspx">Consumer Preview</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Proximity/default.aspx">Proximity</category></item><item><title>Windows 8 Consumer Preview and Visual Studio 11 Beta – What’s New (Part 1/11)</title><link>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-what-s-new-part-1-11.aspx</link><pubDate>Wed, 29 Feb 2012 23:30:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1022988</guid><dc:creator>Alex Golesh</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/rsscomments.aspx?PostID=1022988</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/alex_golesh/commentapi.aspx?PostID=1022988</wfw:comment><comments>http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2012/02/29/windows-8-consumer-preview-and-visual-studio-11-beta-what-s-new-part-1-11.aspx#comments</comments><description>&lt;p&gt;Long awaited Windows 8 Consumer Preview (Win8 CP) just released! &lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_10D78EBD.png" width="1028" height="580" /&gt;&lt;/p&gt;  &lt;p&gt;It is not come alone, but accompanied with Visual Studio 11 Beta (VS11)! Both products available for download. The links are:&lt;/p&gt;  &lt;p&gt;Win8 CP download is available &lt;a href="http://windows.microsoft.com/en-US/windows-8/download" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Visual Studio 11 Express Beta for Windows 8 download available &lt;a href="http://go.microsoft.com/fwlink/?linkid=237572&amp;amp;amp;clcid=0x409" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;So what’s new for developers?&lt;/p&gt;  &lt;p&gt;First think you will meet right after installing VS11 is facelift. Compare – VS2010 &amp;amp; VS11:&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_3B237440.png" width="1028" height="554" /&gt;&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_5B8A6858.png" width="1028" height="737" /&gt;&lt;/p&gt;  &lt;p&gt;VS11 got Metro-ish face lift! The icons are flat and grey, windows got flat look and feel with grey title, even breakpoint marker (red dot) was flattened. Despite the fact I loved Win8 Metro main screen, my first reaction was “%@X&amp;amp;*@%$#@$@!” and I have to admit I was wrong. Now, after using it for quite some time I absolutely love it! &lt;/p&gt;  &lt;p&gt;In next days you will see great many articles and blog posts discussing new features of Win8 CP and the VS11; I will focus on practical part part – how to take your //BUILD DP application run in Win8 CP.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Disclaimer&lt;/em&gt;: I love XAML and C#, thus all my posts will be focused only on those technologies of Win8 Metro development. If you are looking for XAML/C++ or HTML/JavaScript stuff, you should refer to some other wonderful blogs.&lt;/p&gt;  &lt;p&gt;Let’s see how to migrate you BUILD DP timeframe app to Beta. Just opening the application&amp;#39;s solution file with VS11 Beta will not work and you will be getting this kind of experience:&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_25E134CC.png" width="450" height="174" /&gt;&lt;/p&gt;  &lt;p&gt;With the following problem in Output window:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;C:\Users\Alex\Downloads\File access sample\C#\FileAccessSample.csproj : error&amp;#160; : The imported project &amp;quot;C:\Program Files (x86)\MSBuild\Microsoft\WindowsXaml\v1.0\Microsoft.Windows.UI.Xaml.CSharp.targets&amp;quot; was not found. Confirm that the path in the &amp;lt;Import&amp;gt; declaration is correct, and that the file exists on disk.&amp;#160; C:\Users\Alex\Downloads\File access sample\C#\FileAccessSample.csproj&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;While it is possible to open csproj file, change the “&lt;font face="Courier New"&gt;v1.0&lt;/font&gt;” to”&lt;font face="Courier New"&gt;v11.0&lt;/font&gt;” in file path and reload the project in some cases this will render following some of the following errors:&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_011FF788.png" width="357" height="192" /&gt; or &lt;img style="background-image:none;border-right-width:0px;margin:5px 5px 5px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_538EB1F7.png" width="297" height="105" /&gt;&lt;/p&gt;  &lt;p&gt;The best approach to migrate you existing application would be to start brand new “Blank Application” from Windows Metro Style templates and start pulling in your resources, XAML and code files:&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/alex_golesh/image_2C73F2B5.png" width="665" height="294" /&gt;&lt;/p&gt;  &lt;p&gt;After rebuilding your project structure, try to compile you application. It will not compile: the biggest change impacting your work will be accommodating the naming changes in &lt;font face="Courier New"&gt;Windows.UI.ViewManagement.ApplicationLayout&lt;/font&gt;. All names referencing “&lt;em&gt;&lt;u&gt;layout&lt;/u&gt;&lt;/em&gt;” were changed to “&lt;em&gt;&lt;u&gt;view&lt;/u&gt;&lt;/em&gt;”. Enumerations for &lt;font face="Courier New"&gt;ApplicationViewState&lt;/font&gt; now reflect different orientations, so &lt;font face="Courier New"&gt;ApplicationViewState.FullScreen&lt;/font&gt; was split up into &lt;font face="Courier New"&gt;FullScreenLandscape&lt;/font&gt; and &lt;font face="Courier New"&gt;FullScreenPortrait&lt;/font&gt; which you will have to accommodate in your code. &lt;/p&gt;  &lt;p&gt;The event handlers for View state changes have changed and need to be migrated:&lt;/p&gt;  &lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().ViewStateChanged +=        
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; TypedEventHandler&amp;lt;Windows.UI.ViewManagement.ApplicationView, Windows.UI.ViewManagement.ApplicationViewStateChangedEventArgs&amp;gt;(MainPage_ViewStateChanged);&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;Also the handler function signature changed:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;&lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; MainPage_ViewStateChanged(Windows.UI.ViewManagement.ApplicationView sender, Windows.UI.ViewManagement.ApplicationViewStateChangedEventArgs args)
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;{
&lt;/pre&gt;&lt;pre style="background-color:#fbfbfb;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;    &lt;span style="color:#008000;"&gt;//...&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color:#ffffff;margin:0em;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;font-size:12px;"&gt;}&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;This is a common part for all applications, but this is only the beginning. After dealing with this part you are expected to change/fix breaking changes in WinRT APIs – the amount of those changes and possible solution depends entirely on your application’s functionality and used APIs.&lt;/p&gt;

&lt;p&gt;Last, but not least, you must provide new resized graphics for application package such as package logo size is 50x50 (was 56x56), new splash screen size is 620x300 (old was 624x304), badge (if your application uses it) and maybe some others.&lt;/p&gt;

&lt;p&gt;For complete list of breaking changes, please refer to the documentation &lt;a href="http://msdn.microsoft.com/library/windows/apps/hh464920.aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;That’s it for now. In next posts I will show few new (or changed) APIs in Win8 CP. Here are the next planned posts in this series (in no specific order):&lt;/p&gt;

&lt;p&gt;1. &lt;strong&gt;What’s New&lt;/strong&gt; – this post&lt;/p&gt;

&lt;p&gt;2. &lt;strong&gt;Proximity&lt;/strong&gt; – in this post I will show how to use near field communication (NFC) to transmit information between NFC-enabled devices&lt;/p&gt;

&lt;p&gt;3. &lt;strong&gt;Sharing data&lt;/strong&gt; – in this post I will overview how to share the data from your application (“Share source”). Also, I will describe how to build simplest “Share target” application which helps to debug you share source app (and was really helpful for me, since at the time I wrote this series the marketplace apps were not available and I had no app to share my data with)&lt;/p&gt;

&lt;p&gt;4. &lt;strong&gt;Settings&lt;/strong&gt; – in this post I will overview how to use the settings charm and integrate your app settings into it&lt;/p&gt;

&lt;p&gt;5. &lt;strong&gt;Local and roaming data&lt;/strong&gt; – in this post I will overview how to save the data for your application and how to use Win8 CP built-in settings sync functionality to sync your app’s settings&lt;/p&gt;

&lt;p&gt;6. &lt;strong&gt;Sensors&lt;/strong&gt; – in this post I will overview working with some sensors. Since may posts will overview using accelerometer, inclinometer and other “orientation-related” sensors (easier to bind their data to input and showcase) I decided to overview using relatively exotic one- the light sensor and how to use its data in application.&lt;/p&gt;

&lt;p&gt;7. &lt;strong&gt;Licensing (Trial/Full application) and In-App purchases&lt;/strong&gt; – in this post I will overview the different modes of the application, the products which developer can supply for in-app usage and how to debug those features before your application is published.&lt;/p&gt;

&lt;p&gt;8. &lt;strong&gt;Location Service&lt;/strong&gt; – in this post I will overview how to use location information in your app&lt;/p&gt;

&lt;p&gt;9. &lt;strong&gt;Popups&lt;/strong&gt; – in this post I will show how to use new kind of “Message Box” in Win8 CP Metro apps.&lt;/p&gt;

&lt;p&gt;10. &lt;strong&gt;Live tiles, toasts and badges&lt;/strong&gt; &lt;strong&gt;and Push Notifications&lt;/strong&gt; – in this post I will overview how to keep interacting with your user, even when you application is not running anymore. Also I will touch how to deliver push notifications to your application (which used to update tiles, toasts and badges as described in “Live tiles, toasts and badges” post)&lt;/p&gt;

&lt;p&gt;11. &lt;strong&gt;PLM&lt;/strong&gt; &lt;strong&gt;and Custom Splash Screen &lt;/strong&gt;– in this post I will overview product lifecycle management and custom splash screen&lt;/p&gt;

&lt;p&gt;If you are still thinking about downloading and trying Win8 CP and VS11 Beta – think no more! Just go and download!&lt;/p&gt;

&lt;p&gt;Stay tuned for more posts to come,&lt;/p&gt;

&lt;p&gt;Alex&lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1022988" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Csharp/default.aspx">Csharp</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows/default.aspx">Windows</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/HTML/default.aspx">HTML</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Sela/default.aspx">Sela</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Location/default.aspx">Location</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Senssors/default.aspx">Senssors</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/XAML/default.aspx">XAML</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Sharing/default.aspx">Sharing</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Consumer+Preview/default.aspx">Consumer Preview</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Settings/default.aspx">Settings</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Trial/default.aspx">Trial</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Popup/default.aspx">Popup</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/PLM/default.aspx">PLM</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/WinRT/default.aspx">WinRT</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/Roaming/default.aspx">Roaming</category><category domain="http://blogs.microsoft.co.il/blogs/alex_golesh/archive/tags/License/default.aspx">License</category></item></channel></rss>