<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/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>Windows Store Developer Solutions</title><link>http://blogs.msdn.com/b/wsdevsol/</link><description>Information + Context = Solution</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>Dealing with Documents: How (not) to use the documentsLibrary capability in Windows Store apps </title><link>http://blogs.msdn.com/b/wsdevsol/archive/2013/05/09/dealing-with-documents-how-not-to-use-the-documentslibrary-capability-in-windows-store-apps.aspx</link><pubDate>Thu, 09 May 2013 19:12:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10417413</guid><dc:creator>Rob Caplan</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/wsdevsol/rsscomments.aspx?WeblogPostID=10417413</wfw:commentRss><comments>http://blogs.msdn.com/b/wsdevsol/archive/2013/05/09/dealing-with-documents-how-not-to-use-the-documentslibrary-capability-in-windows-store-apps.aspx#comments</comments><description>&lt;p&gt;Many people posting in the forums express confusion over the documentsLibrary capability's "&lt;a title="Special Use" href="http://msdn.microsoft.com/en-us/library/windows/apps/hh464936.aspx#special_use_capabilities"&gt;Special Use&lt;/a&gt;" categorization.&lt;/p&gt;
&lt;p&gt;This capability is highly restricted and not intended for general use, and apps which try to use it generally&amp;nbsp;will fail certification.&lt;/p&gt;
&lt;p&gt;While the requirements that business accounts are required to declare the Special Use capabilities and that only specifically declared file types can be used are what usually&amp;nbsp;catch the eye, the limitation most apps run into is that "the only acceptable use for the &lt;strong&gt;documentsLibrary&lt;/strong&gt; capability is to support the opening of embedded content within another document". This capability is not intended to allow apps to use the documents library as general storage or to allow programmatic browsing of the library. We strongly recommend you avoid using this capability.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;strong&gt;What does an app do if it needs to store user-facing documents?&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The good news is that most apps will be better off without the documentsLibrary. Instead, allow the user the flexibility to choose which folder to use. The first time&amp;nbsp;a document needs to be saved pop up a&amp;nbsp;&lt;a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.pickers.folderpicker.aspx"&gt;FolderPicker&lt;/a&gt; to let the user choose&amp;nbsp;where to place it.&amp;nbsp;Remember the location in the &lt;a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.accesscache.storageapplicationpermissions.futureaccesslist.aspx"&gt;FutureAccessList&lt;/a&gt;&amp;nbsp;so the user only has to choose the first time.&lt;/p&gt;
&lt;p&gt;Users can choose the Documents folder if they want. Users who prefer other locations can choose them. For example: I keep most of my documents in my SkyDrive folders!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For more information on the FolderPicker see &lt;a title="Quickstart: Accessing files with file pickers" href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465199.aspx"&gt;Quickstart: Accessing files with file pickers&lt;/a&gt; and the &lt;a href="http://code.msdn.microsoft.com/windowsapps/File-picker-sample-9f294cba"&gt;File picker sample&lt;/a&gt;. For more information about caching the file access see&amp;nbsp;&lt;a href="http://msdn.microsoft.com/en-us/library/windows/apps/Hh972603"&gt; How to track recently used files and folders&lt;/a&gt;&amp;nbsp;and the &lt;a href="http://go.microsoft.com/fwlink/p/?linkid=231445"&gt;File access sample&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;--Rob&lt;/p&gt;
&lt;p&gt;Follow the Windows Store Developer Solutions team on Twitter @wsdevsol.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10417413" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/_2300_WSDevSol/">#WSDevSol</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Windows+Store/">Windows Store</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Windows+Store+apps/">Windows Store apps</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Picker/">Picker</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/documentsLibrary/">documentsLibrary</category></item><item><title>Your Windows Phone 7/8 application tests fine, but fails after publishing to Marketplace or after private app distribution</title><link>http://blogs.msdn.com/b/wsdevsol/archive/2013/05/08/your-published-windows-phone-7-8-application-fails-to-run.aspx</link><pubDate>Wed, 08 May 2013 14:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10417036</guid><dc:creator>Mark Chamberlain - MSFT</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/wsdevsol/rsscomments.aspx?WeblogPostID=10417036</wfw:commentRss><comments>http://blogs.msdn.com/b/wsdevsol/archive/2013/05/08/your-published-windows-phone-7-8-application-fails-to-run.aspx#comments</comments><description>&lt;p&gt;So, you tested your application using the Windows Phone SDK tools. Everything ran flawlessly. You publish your app. You download your published app. Users download your app and report&amp;nbsp;that&amp;nbsp;the app crashes during its splash screen on start-up. What to do?&lt;/p&gt;
&lt;p&gt;This scenario may occur if:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the app was published to Marketplace, but the app is failing on a phone model that the marketplace testers did not use when validating your app.&lt;/li&gt;
&lt;li&gt;you have deployed your own private&amp;nbsp;&lt;a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206943(v=vs.105).aspx"&gt;Company app distribution&lt;/a&gt;, and therefore the task of testing the app after it has been signed and published is up to you.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;Here is a checklist to help you identify the root cause and solve it.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Make sure that when you built your solution, you did so in Release mode, i.e. not Debug mode. In Visual Studio, check this using &lt;strong&gt;BUILD-&amp;gt;Configuration Manager&amp;hellip;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Make sure you built your solution targeting the Device not the Emulator. The Emulator compiles to the X86 platform while the device compiles to ARM.&lt;/li&gt;
&lt;li&gt;Make sure the XAP file contains all the DLLs needed. For example if using the&lt;a href="http://phone.codeplex.com/"&gt; Windows Phone Toolkit&lt;/a&gt; or other third party libraries, make sure the references to those DLLs indicate CopyLocal=True.&lt;/li&gt;
&lt;li&gt;In Visual Studio, under the PROJECT menu, choose Open Store Test Kit. Execute the automated and manual tests. Make any necessary corrections. More information is available &lt;a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394032(v=vs.105).aspx"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Your XAP file can be found in the Bin/Release folder of your project. Inspect its contents by renaming it from .XAP to .ZIP. Then double click on the newly named file to inspect its contents. You also can inspect it by using a third party tool such as WinZip.&lt;/li&gt;
&lt;li&gt;Also while inspecting the XAP, make sure all the DLLs that are present are known, expected DLLs, and those DLLs have been compiled specifically for use with your particular version of Windows Phone app and build environment. You might need to launch a clean build to ensure there are no stray DLLs.&lt;/li&gt;
&lt;li&gt;In the Dashboard, inspect the list of Capabilities for your published app, and ensure that Marketplace didn&amp;rsquo;t remove any.&amp;nbsp; This problem can occur owing to the various ways Marketplace audits the app in order to identify what capabilities are needed.&amp;nbsp; The solution depends on which capability is missing. As a Windows Phone 7 example, for MediaElement to be detected, its name needs to exist in the xaml itself (x:name). Find more information about Capabilities &lt;a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/gg180730(v=vs.105).aspx"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Make sure all debug APIs such as &lt;a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.scheduler.scheduledactionservice.launchfortest(v=vs.105).aspx"&gt;ScheduledActionService.LaunchForTest&lt;/a&gt; are not included in your release build.&lt;/li&gt;
&lt;li&gt;See if the failure is specific to a particular phone model or manufacturer. For example, determine if the problem is related to the amount of memory available in the phone.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Before Marketplace deploys the app, its ingestion process changes the ProductID in the WMAppManifest.xml. Perhaps your app has some dependency on the ProductID that existed beforehand. An example is if your app has a hard copy of the old ProductID in a string constant. Your app may need to explicitly open WMAppManifest.xml and then inspect the ProductID in order to get the correct value.&lt;/li&gt;
&lt;li&gt;You can submit to Marketplace an &amp;ldquo;instrumented&amp;rdquo; version of their app as a private Beta app, which is not distributed to the public. This version could have logging etc. to make it easier to analyze; particularly if the failure is occurring after the main page has successfully launched.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You should be able to download the call stacks for the crash, by reviewing your App Hub Dashboard crash dump logs. However, sometimes the log results are of limited value. Follow the procedure below in order to enable crash reporting.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;For the phone being tested, go to &lt;strong&gt;settings-&amp;gt;feedback&lt;/strong&gt; and set it to ON.&lt;/li&gt;
&lt;li&gt;Make sure the phone has Wi-Fi access.&lt;/li&gt;
&lt;li&gt;Launch the app.&lt;/li&gt;
&lt;li&gt;Inspect the crash dumps in your App Hub dashboard.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Hope this helps!&lt;/p&gt;
&lt;p&gt;Follow the Windows Store Developer Solutions team on Twitter @wsdevsol&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10417036" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/_2300_WSDevSol/">#WSDevSol</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Windows+Phone+8/">Windows Phone 8</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/WP+8/">WP 8</category></item><item><title>WebView Magic Tricks: Highlight a Search Term</title><link>http://blogs.msdn.com/b/wsdevsol/archive/2013/05/07/webview-magic-tricks-highlight-a-search-term.aspx</link><pubDate>Tue, 07 May 2013 17:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10416741</guid><dc:creator>Matt Small</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/wsdevsol/rsscomments.aspx?WeblogPostID=10416741</wfw:commentRss><comments>http://blogs.msdn.com/b/wsdevsol/archive/2013/05/07/webview-magic-tricks-highlight-a-search-term.aspx#comments</comments><description>&lt;p&gt;WebView continues to be a hot topic in the Windows Store Apps forums.&amp;nbsp; The ability to bring in web content and manipulate it as you wish is a strong desire for many developers.&amp;nbsp; With this blog post, I am starting a series of short videos which demonstrates some simple techniques to make the WebView content more interesting.&lt;/p&gt;
&lt;p&gt;Today's topic is how to highlight search terms in any page which you load into a WebView by injecting and invoking custom-written JavaScript from your C# application.&amp;nbsp; Source code is attached to this post.&amp;nbsp; Enjoy!&lt;/p&gt;
&lt;p&gt;&lt;iframe src="http://www.youtube.com/embed/ocPEVe1s9PI?feature=player_detailpage" frameborder="0" width="640" height="360"&gt;&lt;/iframe&gt;&lt;/p&gt;
&lt;p&gt;If you enjoyed this video, please check out our other videos (more coming soon!) at our &lt;a href="http://www.youtube.com/wsdevsol" target="_blank"&gt;YouTube channel&lt;/a&gt; and be sure to follow us on Twitter @wsdevsol&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10416741" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-41-67-41/WebViewHighlightWords.zip" length="180133" type="application/zip" /></item><item><title>Windows Phone 8: Steps to acquire an Enterprise Mobile Code Signing Certificate required to sign LOB or company apps</title><link>http://blogs.msdn.com/b/wsdevsol/archive/2013/05/01/windows-phone-8-how-to-aquire-enterprise-mobile-code-signing-certificate-required-to-sign-lob-or-company-apps.aspx</link><pubDate>Wed, 01 May 2013 20:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10415479</guid><dc:creator>RashmiA-MSFT</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/wsdevsol/rsscomments.aspx?WeblogPostID=10415479</wfw:commentRss><comments>http://blogs.msdn.com/b/wsdevsol/archive/2013/05/01/windows-phone-8-how-to-aquire-enterprise-mobile-code-signing-certificate-required-to-sign-lob-or-company-apps.aspx#comments</comments><description>&lt;p&gt;If you are developing&amp;nbsp;a Windows Phone 8&amp;nbsp;LOB application&amp;nbsp;to distribute&amp;nbsp;to the&amp;nbsp;users in your company, then the company must acquire an enterprise mobile code signing certificate from Symantec. The company needs this certificate to generate an Application Enrollment Token (AET) and sign company apps.&lt;/p&gt;
&lt;p&gt;Here are&amp;nbsp;step-by-step instructions&amp;nbsp;to acquire an enterprise certificate from Symantec for use on Windows Phone 8.&amp;nbsp;&lt;/p&gt;
&lt;h1&gt;Step 1: Open a Company account and obtain its Publisher ID&lt;/h1&gt;
&lt;p&gt;Enterprise certificates can be acquired for any Dev Center account of type Company (the account can&amp;rsquo;t be an Individual or Student account). As part of establishing the account, the company is validated by Symantec. For &lt;br /&gt;more information about registering for a Dev Center account, see &lt;span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206719(v=vs.105).aspx"&gt;Registration info&lt;/a&gt;&amp;nbsp;.&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;h1&gt;Step 2: Identify the account&lt;/h1&gt;
&lt;p&gt;Open &lt;a href="http://go.microsoft.com/fwlink/?LinkId=268441"&gt;Enterprise Mobile Code Signing Certificate&lt;/a&gt; Web site in the browser.&lt;/p&gt;
&lt;p&gt;Enter the Publisher ID obtained in Step 1, and the associated email address used for the Dev Center account.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: You have to complete Step&amp;nbsp;2 to Step&amp;nbsp;6 on the same computer.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85/5102.Enterprise-Mobile-Code-Signing-Certificate.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85/5102.Enterprise-Mobile-Code-Signing-Certificate.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h1&gt;Step 3: Provide order details and billing information&lt;/h1&gt;
&lt;p&gt;Once the account is identified, you then enter your billing information and accept the agreements and terms for both Symantec and Microsoft.&lt;/p&gt;
&lt;h1&gt;Step 4: Corporate Approval&lt;/h1&gt;
&lt;p&gt;Once the order is submitted, the &lt;strong&gt;Corporate Approver&lt;/strong&gt; receives an email with a link to this site to approve or reject the certificate request.&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h1&gt;Step 5: Certificate pick up&lt;/h1&gt;
&lt;p&gt;After the corporate approver has approved the request, the cert is generated and the submitter receives an email to pick up the certificate.&lt;/p&gt;
&lt;p&gt;Note that &lt;strong&gt;before&lt;/strong&gt; &lt;strong&gt;installing the certificate&lt;/strong&gt;, the CA and Root certificates must be installed in the appropriate certificate store. See the knowledge base link below for the certificate store information..The process to do that is referenced in the email to the submitter, and the certs are attached to that email.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://knowledge.verisign.com/support/code-signing-support/index?page=content&amp;amp;id=SO20770&amp;amp;actp=search&amp;amp;viewlocale=en_US"&gt;How to install the Windows&amp;reg; Phone Private Enterprise Root and Intermediate certificates&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The below screenshots shows the certificate installation process.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85/5226.Enterprise-Mobile-Code-Signing-Certificate-pickup.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85/5226.Enterprise-Mobile-Code-Signing-Certificate-pickup.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85/7343.certificate-import.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85/7343.certificate-import.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85/2210.Certificate-Pickup.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85/2210.Certificate-Pickup.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/strong&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;h1&gt;Step 6: Find certificate in the Cert Store&lt;/h1&gt;
&lt;p&gt;The Enterprise Mobile code signing certificate will be installed in the Personal certificate store on your computer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can&amp;nbsp;now export&amp;nbsp;the certificate in PFX format and use this&amp;nbsp;PFX file to generate an application enrollment token (AET) and sign company apps.&lt;/p&gt;
&lt;p&gt;More information about&amp;nbsp;signing and distributing&amp;nbsp;company apps can be found in the&amp;nbsp;below documentation:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206943(v=vs.105).aspx"&gt;Company app distribution for Windows Phone&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #1f497d; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"&gt;&amp;ldquo;&lt;/span&gt;&lt;span style="color: #1f497d; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;" lang="EN"&gt;Follow us on Twitter @wsdevsol&amp;rdquo; &lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10415479" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Windows+Phone+8/">Windows Phone 8</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Code+signing/">Code signing</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/LOB/">LOB</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Company+apps/">Company apps</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Certificate/">Certificate</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Enterprise/">Enterprise</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/WP+8/">WP 8</category></item><item><title>Incremental Loading of Data using Windows Azure Mobile Services</title><link>http://blogs.msdn.com/b/wsdevsol/archive/2013/04/04/incremental-loading-of-data-using-windows-azure-mobile-services.aspx</link><pubDate>Thu, 04 Apr 2013 15:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10402664</guid><dc:creator>Jeff  Sanders</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/wsdevsol/rsscomments.aspx?WeblogPostID=10402664</wfw:commentRss><comments>http://blogs.msdn.com/b/wsdevsol/archive/2013/04/04/incremental-loading-of-data-using-windows-azure-mobile-services.aspx#comments</comments><description>&lt;p&gt;When your data is in the cloud you should only download information that a user is actually looking at.&amp;nbsp; In the case where you have thousands of items and you want to give the ability to scroll through them you should only fetch the data that the user will be viewing (yes, I know that is a horrible UI design &amp;ndash; another blog opportunity).&amp;nbsp; Chances are they will not make it through the whole list.&lt;/p&gt;
&lt;p&gt;Our XAML controls support being backed by an Incremental loading scheme.&amp;nbsp; I will show how to leverage this by modifying one of our existing samples and use Windows Azure Mobile Services as a backend (because it is really cool)!&lt;/p&gt;
&lt;h1&gt;Prep work:&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;Download the sample we will modify: &lt;a href="http://code.msdn.microsoft.com/windowsapps/Data-Binding-7b1d67b5" target="_blank"&gt;XAML data binding sample&lt;/a&gt; (we will be modifying the C# example).&lt;/li&gt;
&lt;li&gt;Get familiar with &lt;a href="http://www.windowsazure.com/en-us/develop/mobile/" target="_blank"&gt;Windows Azure Mobile Services&lt;/a&gt; if you have not already and go through the &lt;a href="http://www.windowsazure.com/en-us/develop/mobile/tutorials/get-started-with-data-dotnet/" target="_blank"&gt;Get started with data&lt;/a&gt; tutorial (Free Trial link is at the bottom of the page) in which you will &lt;strong&gt;install the Mobile Services SDK&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Add a new Windows Azure Mobile Service for the project and configure it&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;Create a new Mobile Service&lt;/li&gt;
&lt;li&gt;Choose the &amp;lsquo;&lt;span style="font-family: courier new;"&gt;Connect an existing Windows Store app&amp;rsquo;&lt;/span&gt; option from the dashboard of your new project&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/6862.image_5F00_45959D57.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/5775.image_5F00_thumb_5F00_367EBE7D.png" alt="image" width="754" height="263" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Hit the &amp;lsquo;Create Item table&amp;rsquo; button and we will use this for our data (note: this is a different table and will be a different schema than the TodoItem table that you would use for the &amp;lsquo;Create a new Windows Store app&amp;rsquo; option).&lt;/li&gt;
&lt;li&gt;Keep this page up (or return to it later) so we can copy the code listed into our project.&amp;nbsp; You will cut and paste the information from step two here in the following instructions&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Modify the existing sample to use our new Windows Azure Mobile Service&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;Build and run the existing sample to ensure there are no problems, try &amp;lsquo;Scenario 8&amp;rsquo; as this is the section we will modify.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Follow the instructions from the Mobile Service portal&lt;/strong&gt; to &amp;lsquo;Connect an existing Windows Store app&amp;rsquo; from Step 2.&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;In your Visual Studio project, add a reference to the "&lt;code&gt;Windows Azure Mobile Services Client&lt;/code&gt;" extension (did you install the SDK like I told you?).&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/6036.image_5F00_319C0AC1.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/0488.image_5F00_thumb_5F00_7497D92E.png" alt="image" width="617" height="426" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;ul&gt;
&lt;ul&gt;
&lt;li&gt;Add "&lt;code&gt;using Microsoft.WindowsAzure.MobileServices;&lt;/code&gt;", to your &lt;code&gt;App.xaml.cs&lt;/code&gt; file, then copy and paste the following code into your &lt;code&gt;App.xaml.cs&lt;/code&gt; file inside the App &lt;strong&gt;from the portal page you left open above&lt;/strong&gt; into the class definition like this:&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/6355.image_5F00_7A727CC7.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/3125.image_5F00_thumb_5F00_20D46013.png" alt="image" width="677" height="228" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Build to check for any errors&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;Modify Scenario 8 to use our new Mobile Service&lt;/h2&gt;
&lt;p&gt;&amp;lsquo;Scenario 8&amp;rsquo; already uses an incremental loading class so we will modify that scenario and show how easy it is to use Cloud Storage instead of static data.&amp;nbsp; The Mobile Services portal has some instructions on how to connect and existing app to the data.&lt;/p&gt;
&lt;p&gt;Here is where we will deviate slightly from the instructions in your Mobile Service portal.&amp;nbsp; We created a table called &amp;lsquo;Item&amp;rsquo; but the columns do not match what we want for this sample code.&amp;nbsp; Open Scenario8.xaml and look at the binding for the list view.&amp;nbsp; You will see the data is bound to &amp;lsquo;Name&amp;rsquo; and &amp;lsquo;Organization&amp;rsquo;.&amp;nbsp; We could use the &amp;lsquo;Text&amp;rsquo; field in our Mobile Service &amp;lsquo;Item&amp;rsquo; table and remap it to either of these fields in the XAML and create a new column dynamically, but lets create and modify a new table instead.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Back to your Mobile Service portal.&lt;/li&gt;
&lt;li&gt;Click on your newly created Mobile Service and hit the DATA tab.&amp;nbsp; You should see the &amp;lsquo;Item&amp;rsquo; table we created earlier.&lt;/li&gt;
&lt;li&gt;Delete the Item table by hitting the DELETE icon at the bottom of the page&lt;/li&gt;
&lt;li&gt;Then hit the CREATE icon right next to the DELETE icon and create a new table called &amp;lsquo;Employee&amp;rsquo;&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/3716.image_5F00_51F39AB3.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/7345.image_5F00_thumb_5F00_11514E44.png" alt="image" width="347" height="300" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Click on the Employee table after you have created it and you will see it has only one column which is the id column (we will add data with the required columns later).&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/6355.image_5F00_2C89A745.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/1256.image_5F00_thumb_5F00_45194495.png" alt="image" width="539" height="133" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Now lets modify some code we need to attach to our data source&lt;/h3&gt;
&lt;p&gt;There are three files we will be modifying.&amp;nbsp; The first file is &lt;strong&gt;Scenario8.xaml.cs&lt;/strong&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Open this file and find the constructor for GeneratorIncrementalLoadingClass&amp;lt;Employee&amp;gt;.&amp;nbsp; This constructor takes a generator function that pre-populates data.&amp;nbsp; We will be using a data source so lets remove all that garbage!&amp;nbsp; You will see below where I added the new constructor that we will define and commented out the old one.&amp;nbsp; Also, mark the function async and add and await for a new function we will add called initAsync():&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/1157.image_5F00_5689A56D.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/1050.image_5F00_thumb_5F00_15E758FE.png" alt="image" width="712" height="343" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now we will modify the logic for the incremental loading behavior we desire and add the new constructor and initAsync method.&amp;nbsp; This file: &lt;strong&gt;GeneratorIncrementalLoadingClass.cs&lt;/strong&gt; implements the interface we are using and has the old constructor.&amp;nbsp; Open that file and make the following changes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Remove the old constructor and code&amp;nbsp;&amp;nbsp; public GeneratorIncrementalLoadingClass(uint maxCount, Func&amp;lt;int, T&amp;gt; generator)&lt;/li&gt;
&lt;li&gt;Add the new constructor&amp;nbsp; public GeneratorIncrementalLoadingClass(){ }&lt;/li&gt;
&lt;li&gt;Remove Func&amp;lt;int, T&amp;gt; _generator; (it is in the State region at the bottom of the file)&lt;/li&gt;
&lt;li&gt;In LoadMoreItemsOverrideAsync, Delete the&amp;nbsp; code under &amp;rsquo;//Wait for work&amp;rsquo; and &amp;lsquo;//This code simply generates&amp;rsquo;.&lt;/li&gt;
&lt;li&gt;Now your code should look like this (we will add only one line of code to get the table data later):&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/0574.image_5F00_1A787438.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/5758.image_5F00_thumb_5F00_322FAB9E.png" alt="image" width="740" height="335" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add a reference to using Microsoft.WindowsAzure.MobileServices;&lt;/li&gt;
&lt;li&gt;Define a private member that references the employees table from the Mobile Service (note that this is using the &lt;strong&gt;existing&lt;/strong&gt; class definition we already had in our code&amp;hellip; Pretty cool eh?):&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/3782.image_5F00_53280DC5.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/6825.image_5F00_thumb_5F00_47925086.png" alt="image" width="736" height="86" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Now we will define the &amp;lsquo;initAsync&amp;rsquo; function.&amp;nbsp; This function is used to get and set the number of rows in the data source to the variable _maxCount.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/0167.image_5F00_38E7A4A1.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/6837.image_5F00_thumb_5F00_315C3534.png" alt="image" width="614" height="225" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Finally we need to fetch the data from the employee table and return the values.&amp;nbsp; Modify LoadMoreItemsOverrideAsync as pictured (&lt;strong&gt;This is only one line of code we added!).&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/5857.image_5F00_1068C28D.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/1157.image_5F00_thumb_5F00_04D3054E.png" alt="image" width="656" height="170" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The next and last code file we need to modify is &lt;strong&gt;Employee.cs&lt;/strong&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Our table will have an Id member so we simply need to add that to the existing class definition: Modify Employee to have an id:&amp;nbsp; public int Id { get; set; }&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/7506.image_5F00_03FA9F64.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/4762.image_5F00_thumb_5F00_0798BA41.png" alt="image" width="421" height="230" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The final change is to the Manifest.&amp;nbsp; We simply need to add &amp;lsquo;Internet&amp;rsquo; so when we access the Mobile Service the call is allowed out.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/2625.image_5F00_6DC48411.png"&gt;&lt;img style="margin: 0px; display: inline; background-image: none;" title="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/3201.image_5F00_thumb_5F00_06542162.png" alt="image" width="244" height="177" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now compile and run the application.&amp;nbsp; Go to Scenario8 and you should have no data but no errors!&lt;/p&gt;
&lt;h1&gt;Generate sample data&lt;/h1&gt;
&lt;p&gt;Now we need to generate some sample data for our app to show how it is incrementally fetching data.&amp;nbsp; We will use the scheduler in our Mobile Service to do that.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Click on the &amp;lsquo;SCHEDULER&amp;rsquo; item and choose &amp;lsquo;CREATE A SCHEDULED JOB&amp;rsquo;&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/7506.image_5F00_01716DA6.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/6320.image_5F00_thumb_5F00_2BDD9EC3.png" alt="image" width="664" height="191" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Use &amp;lsquo;prepopulate&amp;rsquo; for the name and chose the &amp;lsquo;On demand&amp;rsquo; radio button&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/7002.image_5F00_641C15DB.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/2112.image_5F00_thumb_5F00_3F8A8857.png" alt="image" width="452" height="340" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add this code to insert 1000 records (thanks to Paul Batum for this script)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;function prepopulate() { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var employeeTable = tables.getTable('Employee'); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log("Running 'PrePopulateTable' job."); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var recordsToInsert = 1000; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var batchSize = 10; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var totalCount = 0; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var errorCount = 0; &lt;br /&gt;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; insertItems(); &lt;br /&gt;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; function insertItems() { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var batchCompletedCount = 0; &lt;br /&gt;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var insertComplete = function() { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; batchCompletedCount++; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; totalCount++; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(batchCompletedCount == batchSize) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(totalCount &amp;lt; recordsToInsert) { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; insertItems(); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log("Job 'PrePopulateTable' complete. There were %d errors.", errorCount); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }; &lt;br /&gt;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var errorHandler = function(err) { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; errorCount++; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.warn("Ignoring insert failure as part of batch.", err); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; insertComplete(); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(var i = 0; i &amp;lt; batchSize; i++) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var num = totalCount + i; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var item = { Name: "Name" + num, Organization: "Organization" + num }; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; employeeTable.insert(item, { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; success: insertComplete, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; error: errorHandler &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt; }&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Some notes on this script:&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;I chose to use the same data as the original sample which results in &amp;lsquo;Name1&amp;rsquo; and &amp;lsquo;Organization1&amp;rsquo; etc&amp;hellip; Feel free to get more creative.&lt;/p&gt;
&lt;p&gt;This script avoids an issue that you could hit if you iterate over a simple loop and insert the items.&amp;nbsp; Since the insert is asynchronous you could run out of connections to the SQL backend (this is limited in our scheduler on purpose) and hang your service.&amp;nbsp; So&amp;hellip; use this script which waits for completion before resuming the insert (Paul developed this script for me).&lt;/p&gt;
&lt;p&gt;Note that I am inserting &amp;lsquo;Name&amp;rsquo; and &amp;lsquo;Organization&amp;rsquo; columns and this happens automatically for me thanks to the Dynamic Schema ability of Mobile Services (you can turn that off BTW).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;&amp;lsquo;Save&amp;rsquo; the script&lt;/li&gt;
&lt;li&gt;Hit &amp;lsquo;Run Once&amp;rsquo; and after you get notification that the job has submitted&lt;/li&gt;
&lt;li&gt;Go to the &amp;lsquo;LOGS&amp;rsquo; area of your Dashboard and refresh the page periodically until you see the two messages shown (which the script will write to the log).&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/8078.image_5F00_50FAE92F.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/4265.image_5F00_thumb_5F00_626B4A07.png" alt="image" width="639" height="155" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;The sample data has be populated!&lt;/li&gt;
&lt;li&gt;Go to the &amp;lsquo;DATA&amp;rsquo; tab and see the new records and columns added&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/2210.image_5F00_36BA800B.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85-metablogapi/8176.image_5F00_thumb_5F00_4F4A1D5B.png" alt="image" width="611" height="262" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h1&gt;See the data in action!&lt;/h1&gt;
&lt;p&gt;Now you should be able to Run the app (or hit the refresh button if the app is still up) and see the records incrementally loading!&amp;nbsp; Note how the incremental loading only loads what the user is scrolling to (note the weird scroll bar behavior too since the control does not ask for the total count).&lt;/p&gt;
&lt;h1&gt;Summary&lt;/h1&gt;
&lt;p&gt;You saw how with very few lines of code and very little effort we could add a Cloud based data source using Windows Azure Mobile Services to our existing incremental loading sample.&amp;nbsp; I leave details like updating and records to you but as you learn more about Windows Azure Mobile Services and go through the tutorials you will see how easy that is.&amp;nbsp; Again, loading thousands of items in a list box probably is not the best design for accessing data, however you can see how even loading a few hundred can be more efficient using incremental loading.&amp;nbsp; Attached is a zip that has the code I modified for this example.&lt;/p&gt;
&lt;p&gt;Good luck programming with Windows Azure Mobile Services and Windows Store apps!&amp;nbsp; Be sure to post any questions or comments as you play with these technologies up on the forums (where I hang out a lot lately): &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/category/windowsapps" target="_blank"&gt;Windows Store apps&lt;/a&gt; and &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/azuremobile/threads" target="_blank"&gt;Windows Azure Mobile Services&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Special thanks to Matt Small and Paul Batum for helping me overcome issues when developing this Blog!&amp;nbsp; Don&amp;rsquo;t forget to follow the Windows Store support team on Twitter @wsdevsol.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10402664" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-40-26-64/XAML-data-binding-sample-Incremental.zip" length="309161" type="application/zip" /><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/C_2300_/">C#</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Windows+Store+apps/">Windows Store apps</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Windows+Azure+Mobile+Services/">Windows Azure Mobile Services</category></item><item><title>Using WCF classes to consume a WebService using Plain Old XML (POX) in a Windows Store app</title><link>http://blogs.msdn.com/b/wsdevsol/archive/2013/03/26/using-wcf-classes-to-consume-a-webservice-using-plain-old-xml-pox-in-a-windows-store-app.aspx</link><pubDate>Tue, 26 Mar 2013 01:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10405276</guid><dc:creator>Prashant H Phadke</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/wsdevsol/rsscomments.aspx?WeblogPostID=10405276</wfw:commentRss><comments>http://blogs.msdn.com/b/wsdevsol/archive/2013/03/26/using-wcf-classes-to-consume-a-webservice-using-plain-old-xml-pox-in-a-windows-store-app.aspx#comments</comments><description>&lt;script type="text/javascript"&gt;// &lt;![CDATA[
    function CopyCode(elemName) {
        var obj = document.getElementById(elemName);
        window.clipboardData.setData("Text", obj.innerText);
    }
// ]]&gt;&lt;/script&gt;  &lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;You can leverage WCF functionality from a Windows Store app to call a WebService using Plain Old XML (POX) style of messaging. This blog and the sample included below documents the steps a Windows Store app should perform to consume such a service. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family: calibri; font-size: small;"&gt;The sample is based off the topic of Interoperability with POX applications mentioned here: &lt;a href="http://msdn.microsoft.com/en-us/library/aa738456.aspx" target="_blank"&gt;http://msdn.microsoft.com/en-us/library/aa738456.aspx&lt;/a&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt; Since Windows Store apps do not have an app.config file, this sample shows how a Windows Store app creates a CustomBinding through code. The CustomBinding is created in such a way that we do not use any Message Encoding and just use plain XML to transmit data. The app calls the Web method synchronously, but you can change it to call asynchronously using the BeginRequest/EndRequest methods.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;The blog only covers the Windows Store app implementation and does not cover the implementation of the service. The service code included with this sample exposes the Add, Subtract, Multiply and Divide operations of a Calculator and requires the client to communicate with it using the following XML input body:&lt;/span&gt;&lt;/span&gt;&amp;#160;&lt;/p&gt;  &lt;pre class="scroll"&gt;&lt;span style="background: white; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;Calculator&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;gt;
  &amp;lt;&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;Method&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Add&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;lt;/&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;Method&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;gt;
  &amp;lt;&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;d1&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;2.1&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;d1&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;gt;
  &amp;lt;&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;d2&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;3.2&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;d2&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;Calculator&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;Likewise, the response from the service has the following XML output payload:&lt;/span&gt;&lt;/span&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="scroll"&gt;&lt;span style="background: white; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;CalculatorServiceResponse&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;gt;
  &amp;lt;&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;Method&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Add&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;Method&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;gt;
  &amp;lt;&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;ReturnValue&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;5.3&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;ReturnValue&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;CalculatorServiceResponse&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;The Windows Store app communicates with the Service using the below steps.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: calibri; font-size: small;"&gt;1.)&lt;/span&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;We start off with a “Blank App (XAML)” template&amp;#160; using the Visual C# language and name it POXMessagingClient.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: calibri; font-size: small;"&gt;2.)&lt;/span&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;With the blank project created, we add a Class called Calculator.cs in the client project. This class defines the input XML that the WebService expects (see above), so we will create the class with the same structure like this:&lt;/span&gt;&lt;/span&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="scroll"&gt;&lt;span style="background: white; color: black;"&gt;    [System.Runtime.Serialization.&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;DataContract&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(Namespace = &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;http://tempuri.org/Calculator&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;)]
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;class &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;Calculator
    &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;{
        [System.Runtime.Serialization.&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;DataMember&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;]
        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;public string &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Method;
        [System.Runtime.Serialization.&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;DataMember&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;]
        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;public double &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;d1;
        [System.Runtime.Serialization.&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;DataMember&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;]
        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;public double &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;d2;
    }&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;3.)&amp;#160;&amp;#160;&amp;#160; Similarly, we create a class that will correspond with the WebService response/ output format. To do that, create a class and name is CalculatorServiceResponse.cs and add the following contents: &lt;/p&gt;

&lt;pre class="scroll"&gt;&lt;span style="background: white; color: black;"&gt;    [System.Runtime.Serialization.&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;DataContract&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(Namespace = &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;http://tempuri.org/CalculatorServiceResponse&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;)]
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;public class &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;CalculatorServiceResponse
    &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;{
        [System.Runtime.Serialization.&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;DataMember&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;]
        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;public &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;String &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Method;
        [System.Runtime.Serialization.&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;DataMember&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;]
        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;public &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;String &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;ReturnValue;
    }&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;span style="font-family: calibri; font-size: small;"&gt;4.)&lt;/span&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;With the input and output structures declared, the next step is to implement a class that will actually call into the remote WebService. Add a class called CustomCalculatorClient.cs and then inherit it from the ClientBase&amp;lt;IRequestChannel&amp;gt; class. You also need to add the references to System.ServiceModel and System.ServiceModel.Channels as follows:&lt;/span&gt;&lt;/span&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="scroll"&gt;&lt;span style="background: white; color: black;"&gt;    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;System.ServiceModel;
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;System.ServiceModel.Channels;
    ...
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;class &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;CustomCalculatorClient &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;: &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;ClientBase&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;IRequestChannel&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&amp;gt;
    {
    }&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;span style="font-family: calibri; font-size: small;"&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: calibri; font-size: small;"&gt;5.)&lt;/span&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;Add a method called CreatePoxBinding that will generate a CustomBinding used to invoke the WebService. In this function we first create a TextMessageEncodingBindingElement and pass the first parameter to its constructor as MessageVersion.None. This indicates that a SOAP envelope will not be required. Then we create an HttpTransportBindingElement and then create a CustomBinding instance and pass in the 2 binding elements we just created. The function looks like this:&lt;/span&gt;&lt;/span&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="scroll"&gt;&lt;span style="background: white; color: black;"&gt;        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;private static &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;Binding &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;CreatePoxBinding()
        {
            &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;TextMessageEncodingBindingElement &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;encoder = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;TextMessageEncodingBindingElement&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;MessageVersion&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.None, &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;Encoding&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.UTF8);

            &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;HttpTransportBindingElement &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;transport = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;HttpTransportBindingElement&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;();
            transport.ManualAddressing = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;true&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;;

            &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;return new &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;CustomBinding&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;BindingElement&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;[] { encoder, transport });
        }&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;span style="font-family: calibri; font-size: small;"&gt;6.)&lt;/span&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;To associate this CustomBinding with our class, we add a constructor to our CustomCalculatorClient like this:&lt;/span&gt;&lt;/span&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="scroll"&gt;&lt;span style="background: white; color: black;"&gt;        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;public &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;CustomCalculatorClient(&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;Uri &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;baseUri)
            : &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;base&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;CustomCalculatorClient&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.CreatePoxBinding(), &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;EndpointAddress&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;( baseUri ) )
        {
        }&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;span style="font-family: calibri; font-size: small;"&gt;7.)&lt;/span&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;Add a method called PostAsync that will create the underlying WCF Channel request and call the remote service asynchronously. In this function call Message.CreateMessage where we pass in the entityBody for the request. The entityBody parameter will be an instance of the Calculator class with the Method, d1 and d2 parameters that the service expects. The actual conversion of an object to an XML payload will be handled internally. The functions look like this:&lt;/span&gt;&lt;/span&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="scroll"&gt;&lt;span style="background: white; color: black;"&gt;        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;public &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;IAsyncResult &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;PostAsync(&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;Uri &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;requestUri, &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;object &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;entityBody, &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;AsyncCallback &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;callback, &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;object &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;state)
        {
            &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;Message &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;request = &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;Message&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.CreateMessage(&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;MessageVersion&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.None, &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;String&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.Empty, entityBody);
            request.Headers.To = requestUri;

            &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;HttpRequestMessageProperty &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;property = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;HttpRequestMessageProperty&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;();
            property.Method = &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;POST&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;;

            request.Properties.Add(&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;HttpRequestMessageProperty&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.Name, property);
            &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;return this&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.Channel.BeginRequest(request, callback, state);
        }&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;span style="font-family: calibri; font-size: small;"&gt;8.)&amp;#160;&amp;#160;&amp;#160; &lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;Notice that since this function is asynchronous, the BeginRequest function expects a callback function as well as a state object that will be used when the function call completes. These parameters are passed from the calling functions in MainPage.xaml. The callback function is called&amp;#160; RespCallback and you can find it in the MainPage.xaml page and its implementation is as follows:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;pre class="scroll"&gt;&lt;span style="background: white; color: black;"&gt;        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;private async void &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;RespCallback(&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;IAsyncResult &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;asyncResult)
        {
            &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;try
            &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;{
                &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;IRequestChannel &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;channel = (&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;IRequestChannel&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;)asyncResult.AsyncState; 
                &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;Message &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;response = channel.EndRequest(asyncResult);
                &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;CalculatorServiceResponse &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;oCalcResp = response.GetBody&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;CalculatorServiceResponse&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&amp;gt;();
                &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;String &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;strOutput = &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Result of &amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ oCalcResp.Method +&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;=&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ oCalcResp.ReturnValue;

                &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;await this&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.Dispatcher.RunAsync(Windows.UI.Core.&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;CoreDispatcherPriority&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.Normal, &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Windows.UI.Core.&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;DispatchedHandler&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(() =&amp;gt;
                {
                    txtOutput.Text = strOutput;
                }));
            }
            &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;catch &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;Exception &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;oEx)
            {
                &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// handle the exception
                &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;this&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.Dispatcher.RunAsync(Windows.UI.Core.&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;CoreDispatcherPriority&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.Normal, &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Windows.UI.Core.&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;DispatchedHandler&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(() =&amp;gt;
                {
                    txtOutput.Text = &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;There was an exception: &amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ oEx.Message;
                })).AsTask().Wait();
            }
        }&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;span style="font-family: calibri; font-size: small;"&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: calibri; font-size: small;"&gt;9.)&lt;/span&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;The other two functions that are present in the CustomCalculatorClient.cs file – GetStatusCode and GetStatusDescription only extract the HTTP response code and the status description of the HTTP response.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: calibri; font-size: small;"&gt;10.)&lt;/span&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;MainPage.xaml has 4 buttons that handle each of the 4 operations - Add, Subtract, Multiply and Divide, 2 textboxes that accept the input parameters and a TextBlock that displays the output.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: calibri; font-size: small;"&gt;&amp;#160;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: calibri; font-size: small;"&gt;11.)&lt;/span&gt; &lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;The click of the Add button has the following implementation:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: calibri; font-size: small;"&gt;&amp;#160;&lt;/span&gt;&lt;/p&gt;

&lt;pre class="scroll"&gt;&lt;span style="background: white; color: black;"&gt;        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;private void &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;btnAdd_Click(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;object &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;sender, &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;RoutedEventArgs &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;e)
        {
            &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;try
            &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;{
                &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;Calculator &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;oCalc = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;Calculator&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;();
                &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;CustomCalculatorClient &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;oCalcClient = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;CustomCalculatorClient&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(serviceLocation);
                oCalc.Method = &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Add&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;;
                oCalc.d1 = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;double&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.Parse(txtInput1.Text);
                oCalc.d2 = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;double&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.Parse(txtInput2.Text);

                &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;IAsyncResult &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;result = oCalcClient.PostAsync(serviceLocation, oCalc, RespCallback, oCalcClient.InnerChannel);
            }
            &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;catch &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;Exception &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;oEx)
            {
                txtOutput.Text = &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Add exception: &amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ oEx.Message;
            }
        }&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;The above function creates an instance of the Calculator class – that populates the requested method (Add) and then assigns the input parameters: d1 and d2.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: calibri; font-size: small;"&gt;&amp;#160;&lt;/span&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;An instance of the CustomCalculatorClient class is then created where we pass in the location of the remote service – serviceLocation that is set to &lt;a href="http://localhost:8001/CalculatorService"&gt;http://localhost:8001/CalculatorService&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: calibri; font-size: small;"&gt;&amp;#160;&lt;/span&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Note&lt;/u&gt;: The server address here is set to localhost and is for demonstration purposes only. For an actual Windows Store app, you cannot use localhost as the server address.&lt;/strong&gt;&lt;/p&gt;
&lt;strong&gt;&lt;/strong&gt;

&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;Next the PostAsync method is called, which will be responsible for sending the HTTP request asynchronously to the Service. The response processing happens in the RespCallback function as described in Step 7 that will extract the response body and display the results to the user.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: calibri;"&gt;&lt;span style="font-size: small;"&gt;To run the project, compile the solution and start an elevated command prompt from where you will start the POXMessagingService service. By default, the service starts listening on the &lt;/span&gt;&lt;a href="http://localhost:8001/CalculatorService"&gt;http://localhost:8001/CalculatorService&lt;/a&gt;&lt;span style="font-size: small;"&gt; URI location. If you have other applications listening on port 8001, please change the port references to another port in both the projects. Alternately, start Visual Studio as an Administrator and then set the Startup Project to the POXMessagingService project (Right click on the POXMessagingService Project, and then select &amp;quot;Set as Startup Project&amp;quot;).&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;Once the service is started, you can start your POXMessagingClient Windows Store app and then use the Add, Subtract, Multiply, Divide operations on the remote service. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;This shows how you can consume a WebService using simple XML from a Windows Store app.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: calibri;"&gt;Follow us on Twitter @wsdevsol.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: calibri; font-size: small;"&gt;&amp;#160;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10405276" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-40-52-76/POXMessaging.zip" length="31695" type="application/zip" /><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/C_2300_/">C#</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Windows+Store+apps/">Windows Store apps</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/WCF/">WCF</category></item><item><title>Datagram Socket Communication in Windows Phone 8</title><link>http://blogs.msdn.com/b/wsdevsol/archive/2013/03/19/datagram-socket-communication-in-windows-phone-8.aspx</link><pubDate>Tue, 19 Mar 2013 20:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10403675</guid><dc:creator>Mark Chamberlain - MSFT</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/wsdevsol/rsscomments.aspx?WeblogPostID=10403675</wfw:commentRss><comments>http://blogs.msdn.com/b/wsdevsol/archive/2013/03/19/datagram-socket-communication-in-windows-phone-8.aspx#comments</comments><description>&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;New to Windows Phone 8 is the &lt;strong&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.sockets.aspx"&gt;Windows.Networking.Sockets&lt;/a&gt;&amp;nbsp;&lt;/strong&gt;namespace. This namespace is also used in the Windows Store app development environment, which makes it convenient for developers who wish to port networking applications to both targets.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;strong&gt;Windows.Networking.Sockets &lt;/strong&gt;is the replacement for the older &lt;strong&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.net.sockets.socket(v=vs.105).aspx"&gt;System.Net.Sockets&lt;/a&gt;&amp;nbsp;&lt;/strong&gt;namespace used in the Windows Phone 7 network model. &amp;nbsp;&lt;strong&gt;System.Net.Sockets &lt;/strong&gt;is provided for Windows Phone 7 compatibility purposes and is not recommended for new Windows Phone 8 projects.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;This blog includes a Windows Phone 8 sample sockets application, Datagram Demo.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;Datagram Demo implements UDP Datagrams (Unicast and Multicast), and demonstrates direct phone-to-phone communication using WiFi.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small; text-decoration: underline;"&gt;Procedure&lt;/span&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;Download and unzip the project file found at the end of this blog. &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;Obtain two Windows Phone 8 devices. Compile and then deploy the sample application to both phones.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;Connect both phones to the same WiFi access point. The access point must support DHCP in order to automatically assign IP addresses to the phones.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;Launch the application on both phones.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;Touch the Multicast Inquire button on one phone, to discover other phones on the local WiFi access point, by transmitting a Multicast UDP packet (&amp;ldquo;WhoIsThere&amp;rdquo;). &amp;nbsp;All phones (including the inquiring phone) respond by sending a Unicast UDP packet (&amp;ldquo;AckHereIam&amp;rdquo;) &amp;nbsp;back to the phone that made the inquiry. The inquiring phone will report the IP address of each received AckHereIam packet to the main screen of the app.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;The user can then choose and tap an IP address on the screen in order to communicate with that phone.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;A second screen appears, &amp;ldquo;Communication Log&amp;rdquo;.&amp;nbsp; Touch the Ping button. This will send a Unicast UDP packet (&amp;ldquo;Ping&amp;rdquo;) message to the chosen phone. The chosen phone will receive that message and respond by sending a unicast UDP Packet (&amp;ldquo;Pong&amp;rdquo;) back to the inquiring phone that originated the communication.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;Responses from a multicast inquiry may include packets from seemingly unexpected sources.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;If you run the app in the emulator, a multicast inquiry will return multiple devices. In fact the responses come from the same emulator instance. The emulator has more than one IP address assigned to it. An IPaddress&amp;nbsp;of 127.0.0.1 is the local loopback (&lt;a href="http://en.wikipedia.org/wiki/Localhost"&gt;local host&lt;/a&gt;) address of the PC. An IP address starting with 169.254&amp;hellip; is a &lt;a href="http://en.wikipedia.org/wiki/Link-local_address"&gt;Link-Local&lt;/a&gt; address. The app filters out those addresses. If you wish to see all the addresses you may comment out the filtering code.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;If you run the app in a real phone, the IP addresses of interest typically begin with 192.168&amp;hellip; on a standard WiFi network. However if your phone is connected to your mobile cellular service, on your inquiry screen you may also see an IP address corresponding to the cellular service. The IP address may begin with 10.&amp;nbsp; That address does not appear to be useful for multicast inquiries.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;UDP or TCP?&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;This sample demonstrates &lt;a href="http://en.wikipedia.org/wiki/User_Datagram_Protocol" target="_blank"&gt;User Datagram Protocol (UDP)&lt;/a&gt; sockets. UDP has no built-in handshaking dialogs to guarantee packet delivery, which means that it is up to you, the developer to accommodate any unreliability in the network.&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt; Nor does it guarantee the order in which packets are received.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;When using UDP socket connections, consider including your own mechanisms to properly order packets and retry sending packets etc. as needed, depending on your particular scenario and reliability requirements of your application.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;You can leverage &lt;a href="http://en.wikipedia.org/wiki/Transmission_Control_Protocol" target="_blank"&gt;Transmission Control Protocol (TCP)&lt;/a&gt; to automatically provide reliable and correctly ordered delivery of a stream of data.&amp;nbsp;&amp;nbsp;Since only UDP supports multicasting, you can use UDP initially in order to discover other devices or computers to communicate with, and then establish a TCP connection using the &lt;a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/windows.networking.sockets.streamsocket.aspx"&gt;StreamSocket&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/windows.networking.sockets.streamsocketlistener.aspx"&gt;StreamSocketListener &lt;/a&gt;classes.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;Some earlier phone brands did not properly detect multicast packets.&amp;nbsp;If you find that multicasting is not working in a specific physical phone device, make sure the phone has the latest operating system version.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;You can update the phone via &lt;strong&gt;Settings-&amp;gt;system-&amp;gt;phone update&lt;/strong&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;Happy networking!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;--Mark&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;strong&gt;&lt;span style="text-decoration: underline;"&gt;Additional resources&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202874(v=vs.105).aspx"&gt;Sockets for Windows Phone&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://www.codeproject.com/Tips/505487/DNS-resolving-and-Parsing-IP-Address-in-Metro-Styl"&gt;Code Project: DNS resolving and Parsing IP Address in Metro Style Applications(WinRT)&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh487166(v=vs.105).aspx"&gt;MSDN: How to detect network changes for Windows Phone&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202863(v=vs.105).aspx"&gt;MSDN: How to get connection information about a socket for Windows Phone&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://en.wikipedia.org/wiki/User_Datagram_Protocol"&gt;Wikipedia: User_Datagram_Protocol&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://channel9.msdn.com/Series/Building-Apps-for-Windows-Phone-8-Jump-Start/Building-Apps-for-Windows-Phone-8-Jump-Start-11-Network-Communication-in-Windows-Phone-8"&gt;Channel 9: Building Apps for Windows Phone 8 Jump Start: (11) Network Communication&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://code.msdn.microsoft.com/site/search?query=networking&amp;amp;f%5B0%5D.Value=networking&amp;amp;f%5B0%5D.Type=SearchText&amp;amp;f%5B1%5D.Value=Phone&amp;amp;f%5B1%5D.Type=Platform&amp;amp;f%5B1%5D.Text=Phone&amp;amp;ac=4"&gt;MSDN Developer Code Samples (Phone + networking)&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;Follow us on Twitter @wsdevsol!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10403675" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-40-36-75/DatagramSocket.zip" length="123325" type="application/zip" /><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/_2300_WSDevSol/">#WSDevSol</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Windows+8/">Windows 8</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Windows+Phone+8/">Windows Phone 8</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Sockets/">Sockets</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Networking/">Networking</category></item><item><title>Mixed Media – Audio &amp; Video – Windows Store vs. Windows Phone 8</title><link>http://blogs.msdn.com/b/wsdevsol/archive/2013/03/08/mixed-media-audio-amp-video-windows-store-vs-windows-phone-8.aspx</link><pubDate>Fri, 08 Mar 2013 00:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10400521</guid><dc:creator>James Dailey - MSFT</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/wsdevsol/rsscomments.aspx?WeblogPostID=10400521</wfw:commentRss><comments>http://blogs.msdn.com/b/wsdevsol/archive/2013/03/08/mixed-media-audio-amp-video-windows-store-vs-windows-phone-8.aspx#comments</comments><description>&lt;div class="WordSection1"&gt;
&lt;p class="MsoTitle"&gt;&lt;span style="font-size: small;"&gt;As everyone knows, with the release of Windows 8 and Windows Phone 8 we have brought the two platforms closer together than ever before. The keyword here is &amp;ldquo;closer&amp;rdquo;. There are still some fairly major implementation and terminology differences between the two platforms particularly when working with digital audio and video. Hopefully this article will help you map and understand the media technologies between the two platforms. In this article I&amp;rsquo;m assuming that you are familiar with the media technologies on one platform or the other and just need some hints how to migrate your code to the other platform.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoTitle"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoTitle"&gt;&lt;span style="font-size: xx-large;"&gt;Audio / Video Playback Technologies&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;table class="MsoTableGrid" style="border: currentColor; border-collapse: collapse;" border="1" cellspacing="0" cellpadding="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="background: #d0cece; padding: 0in 5.4pt; border: 1pt solid windowtext; width: 467.5pt;" colspan="2" valign="top" width="623"&gt;
&lt;h2 style="text-align: center; line-height: normal;" align="center"&gt;Audio / Video Playback &amp;ndash; Technology Map&lt;/h2&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="background: #d5dce4; border-width: medium 1pt 1pt; border-style: none solid solid; border-color: currentColor windowtext windowtext; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;h3 style="text-align: center; line-height: normal;" align="center"&gt;Windows Store&lt;/h3&gt;
&lt;/td&gt;
&lt;td style="background: #d5dce4; border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;h3 style="text-align: center; line-height: normal;" align="center"&gt;Windows Phone 8&lt;/h3&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="border-width: medium 1pt 1pt; border-style: none solid solid; border-color: currentColor windowtext windowtext; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;MediaElement (XAML)&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;MediaElement (XAML)&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="background: #e7e6e6; border-width: medium 1pt 1pt; border-style: none solid solid; border-color: currentColor windowtext windowtext; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;IMFMediaEngine (C++ only)&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="background: #e7e6e6; border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;IMFMediaEngine (C++ only) (Subset)&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="border-width: medium 1pt 1pt; border-style: none solid solid; border-color: currentColor windowtext windowtext; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;WASAPI (C++ only)&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;WASAPI (C++ only) (Subset)&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="background: #e7e6e6; border-width: medium 1pt 1pt; border-style: none solid solid; border-color: currentColor windowtext windowtext; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;XAudio2 (C++ only)&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="background: #e7e6e6; border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;XAudio2 (C++ only)&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;The MediaElement will likely be your &amp;ldquo;go to&amp;rdquo; control on both platforms for playing audio and video. There are a few differences though. You can&amp;rsquo;t add audio or video effects (plug-ins) to the MediaElement on the phone. The DRM implementation is also quite different between the two platforms. If you are not doing anything &amp;ldquo;fancy&amp;rdquo; you should be able to port your MediaElement implementation with no problem.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;The MediaEngine (different from the MediaElement discussed above) is new for both platforms in version 8. On both platforms the MediaEngine can only be used from C++ and is not currently supported from managed code. The phone also has slightly reduced functionality. On the phone the MediaEngine only supports frame-server mode. Also keep in mind that on the phone hardware acceleration will always be used.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;WASAPI and XAudio2 are also supported on both platforms. Unfortunately at this time these audio only technologies can only be called from C++. They are not currently supported from managed code. While the full XAudio2 functionality is supported on both platforms keep in mind that XAudio2 only supports uncompressed PCM audio on the phone. It is extremely difficult to use XAudio2 with compressed media formats on the phone at this time. The phone also only supports a subset of the WASAPI Core Audio APIs as well.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;table class="MsoTableGrid" style="border: currentColor; border-collapse: collapse;" border="1" cellspacing="0" cellpadding="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="background: #d0cece; padding: 0in 5.4pt; border: 1pt solid windowtext; width: 467.5pt;" colspan="4" valign="top" width="623"&gt;
&lt;h2 style="text-align: center; line-height: normal;" align="center"&gt;References&lt;/h2&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="background: #d5dce4; border-width: medium 1pt 1pt; border-style: none solid solid; border-color: currentColor windowtext windowtext; padding: 0in 5.4pt; width: 211.25pt;" colspan="2" valign="top" width="282"&gt;
&lt;h3 style="text-align: center; line-height: normal;" align="center"&gt;Windows Store app&lt;/h3&gt;
&lt;/td&gt;
&lt;td style="background: #d5dce4; border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 256.25pt;" colspan="2" valign="top" width="342"&gt;
&lt;h3 style="text-align: center; line-height: normal;" align="center"&gt;Windows Phone 8 app&lt;/h3&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 32.8pt;"&gt;
&lt;td style="border-width: medium 1pt 1pt; border-style: none solid solid; border-color: currentColor windowtext windowtext; padding: 0in 5.4pt; width: 211.25pt; height: 32.8pt;" colspan="2" valign="top" width="282"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh452756.aspx"&gt;Win32 and COM for Windows Store apps (multimedia)&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 256.25pt; height: 32.8pt;" colspan="2" valign="top" width="342"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206944(v=vs.105).aspx"&gt;Native audio APIs for Windows Phone 8&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 32.8pt;"&gt;
&lt;td style="padding: 0in 5.4pt; border: 1pt solid windowtext; width: 211.25pt; height: 32.8pt;" colspan="2" valign="top" width="282"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windows/desktop/hh447918(v=vs.85).aspx"&gt;IMFMediaEngine interface (Windows)&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 256.25pt; height: 32.8pt;" colspan="2" valign="top" width="342"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj681688(v=vs.105).aspx"&gt;Supported Microsoft Media Foundation APIs for Windows Phone 8&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 32.8pt;"&gt;
&lt;td style="border-width: medium 1pt 1pt; border-style: none solid solid; border-color: currentColor windowtext windowtext; padding: 0in 5.4pt; width: 211.25pt; height: 32.8pt;" colspan="2" valign="top" width="282"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.mediaelement.aspx"&gt;MediaElement class (Windows)&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 256.25pt; height: 32.8pt;" colspan="2" valign="top" width="342"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.controls.mediaelement(v=vs.105).aspx"&gt;MediaElement Class&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="border: currentColor;" width="0"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td style="border: currentColor;" width="281"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td style="border: currentColor;" width="0"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td style="border: currentColor;" width="341"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td style="border: currentColor;" width="0"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoTitle"&gt;&lt;span style="font-size: xx-large;"&gt;Background Audio&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;table class="MsoTableGrid" style="border: currentColor; border-collapse: collapse;" border="1" cellspacing="0" cellpadding="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="background: #d0cece; padding: 0in 5.4pt; border: 1pt solid windowtext; width: 467.5pt;" colspan="2" valign="top" width="623"&gt;
&lt;h2 style="text-align: center; line-height: normal;" align="center"&gt;Background Audio &amp;ndash; Technology Map&lt;/h2&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="background: #d5dce4; border-width: medium 1pt 1pt; border-style: none solid solid; border-color: currentColor windowtext windowtext; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;h3 style="text-align: center; line-height: normal;" align="center"&gt;Windows Store (XAML / HTML5)&lt;/h3&gt;
&lt;/td&gt;
&lt;td style="background: #d5dce4; border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;h3 style="text-align: center; line-height: normal;" align="center"&gt;Windows Phone 8 (XAML)&lt;/h3&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="border-width: medium 1pt 1pt; border-style: none solid solid; border-color: currentColor windowtext windowtext; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;MediaElement / Audio tag&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;BackgroundAudioPlayer&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="background: #e7e6e6; border-width: medium 1pt 1pt; border-style: none solid solid; border-color: currentColor windowtext windowtext; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;msAudioCategory="BackgroundCapableMedia"&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="background: #e7e6e6; border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;AudioPlayerAgent&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="border-width: medium 1pt 1pt; border-style: none solid solid; border-color: currentColor windowtext windowtext; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;Windows.Media.MediaControl&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;Universal Volume Control (UVC)&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="background: #e7e6e6; border-width: medium 1pt 1pt; border-style: none solid solid; border-color: currentColor windowtext windowtext; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;Media Foundation Source (C++ only)&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="background: #e7e6e6; border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;MediaStreamSource&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;The big difference playing background audio in a Windows Store app vs. Windows Phone 8 app is the use of the BackgroundAudioPlayer on the Phone and the MediaElement / Audio tag for Windows Store apps. The BackgroundAudioPlayer is a static class that can be used without needing instantiation. The MediaElement and Audio tags must be defined in markup before they can be used.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;For your Windows Store app you must set MsAudioCategory=&amp;rdquo;BackgroundCapableMedia&amp;rdquo;. For your phone app you need to create an AudioPlayerAgent that will run in the background when your app gets swapped out.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;The final thing to note is that on both platforms you need to handle user input from the lock screen media controls. On the phone we call these controls the &amp;ldquo;Universal Volume Control&amp;rdquo; (UVC) and in your Store app we call them the &amp;ldquo;media controls&amp;rdquo;. Different terms but the same basic functionality.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;
&lt;table class="MsoTableGrid" style="border: currentColor; border-collapse: collapse;" border="1" cellspacing="0" cellpadding="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="background: #d0cece; padding: 0in 5.4pt; border: 1pt solid windowtext; width: 467.5pt;" colspan="2" valign="top" width="623"&gt;
&lt;h2 style="text-align: center; line-height: normal;" align="center"&gt;References&lt;/h2&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="background: #d5dce4; border-width: medium 1pt 1pt; border-style: none solid solid; border-color: currentColor windowtext windowtext; padding: 0in 5.4pt; width: 211.25pt;" valign="top" width="282"&gt;
&lt;h3 style="text-align: center; line-height: normal;" align="center"&gt;Windows Store app&lt;/h3&gt;
&lt;/td&gt;
&lt;td style="background: #d5dce4; border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 256.25pt;" valign="top" width="342"&gt;
&lt;h3 style="text-align: center; line-height: normal;" align="center"&gt;Windows Phone 8 app&lt;/h3&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 32.8pt;"&gt;
&lt;td style="border-width: medium 1pt 1pt; border-style: none solid solid; border-color: currentColor windowtext windowtext; padding: 0in 5.4pt; width: 211.25pt; height: 32.8pt;" valign="top" width="282"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windows/apps/Hh700367.aspx"&gt;How to play audio in the background (Windows Store apps using JavaScript and HTML)&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 256.25pt; height: 32.8pt;" valign="top" width="342"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394039(v=vs.105).aspx"&gt;Background audio overview for Windows Phone&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p class="MsoTitleCxSpFirst"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoTitleCxSpLast"&gt;&lt;span style="font-size: xx-large;"&gt;Sharing Media&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;table class="MsoTableGrid" style="border: currentColor; border-collapse: collapse;" border="1" cellspacing="0" cellpadding="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="background: #d0cece; padding: 0in 5.4pt; border: 1pt solid windowtext; width: 467.5pt;" colspan="2" valign="top" width="623"&gt;
&lt;h2 style="text-align: center; line-height: normal;" align="center"&gt;Sharing Media &amp;ndash; Technology Map&lt;/h2&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="background: #d5dce4; border-width: medium 1pt 1pt; border-style: none solid solid; border-color: currentColor windowtext windowtext; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;h3 style="text-align: center; line-height: normal;" align="center"&gt;Windows Store (XAML / HTML5)&lt;/h3&gt;
&lt;/td&gt;
&lt;td style="background: #d5dce4; border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;h3 style="text-align: center; line-height: normal;" align="center"&gt;Windows Phone 8 (XAML)&lt;/h3&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="border-width: medium 1pt 1pt; border-style: none solid solid; border-color: currentColor windowtext windowtext; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;DataTransferManager class&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 233.75pt;" valign="top" width="312"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;ShareMediaTask Class&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;The big difference here is that with Windows Store apps the user initiates the sharing process using the &amp;ldquo;share charm&amp;rdquo;. On the phone your app will need to invoke the ShareMediaTask directly from within your code.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;In both cases you will likely never get confirmation that your data was successfully shared. In essence it&amp;rsquo;s a &amp;ldquo;fire and forget&amp;rdquo; operation.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;Keep in mind that on the phone your app will be swapped out and may get shut down when the app you are sharing with takes up the full screen. Because of this you may need to save state.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;table class="MsoTableGrid" style="border: currentColor; border-collapse: collapse;" border="1" cellspacing="0" cellpadding="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="background: #d0cece; padding: 0in 5.4pt; border: 1pt solid windowtext; width: 467.5pt;" colspan="2" valign="top" width="623"&gt;
&lt;h2 style="text-align: center; line-height: normal;" align="center"&gt;References&lt;/h2&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="background: #d5dce4; border-width: medium 1pt 1pt; border-style: none solid solid; border-color: currentColor windowtext windowtext; padding: 0in 5.4pt; width: 211.25pt;" valign="top" width="282"&gt;
&lt;h3 style="text-align: center; line-height: normal;" align="center"&gt;Windows Store app&lt;/h3&gt;
&lt;/td&gt;
&lt;td style="background: #d5dce4; border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 256.25pt;" valign="top" width="342"&gt;
&lt;h3 style="text-align: center; line-height: normal;" align="center"&gt;Windows Phone 8 app&lt;/h3&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="border-width: medium 1pt 1pt; border-style: none solid solid; border-color: currentColor windowtext windowtext; padding: 0in 5.4pt; width: 211.25pt;" valign="top" width="282"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windows/apps/Hh758314.aspx"&gt;Sharing and receiving content (Windows Store apps using JavaScript and HTML) (Windows)&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-width: medium 1pt 1pt medium; border-style: none solid solid none; border-color: currentColor windowtext windowtext currentColor; padding: 0in 5.4pt; width: 256.25pt;" valign="top" width="342"&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207027(v=vs.105).aspx"&gt;How to use the share media task for Windows Phone&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;Follow us on Twitter @wsdevsol.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10400521" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/WindowsStoreApps/">WindowsStoreApps</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Windows+Store+Application+Solutions+Developer/">Windows Store Application Solutions Developer</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/WSDS/">WSDS</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Windows+Store+apps/">Windows Store apps</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Video/">Video</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Media/">Media</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Audio/">Audio</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/MediaEngine/">MediaEngine</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Windows+Phone+8/">Windows Phone 8</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/MediaElement/">MediaElement</category></item><item><title>Where did all my gestures go?</title><link>http://blogs.msdn.com/b/wsdevsol/archive/2013/02/16/where-did-all-my-gestures-go.aspx</link><pubDate>Sat, 16 Feb 2013 06:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10394216</guid><dc:creator>Rob Caplan</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/wsdevsol/rsscomments.aspx?WeblogPostID=10394216</wfw:commentRss><comments>http://blogs.msdn.com/b/wsdevsol/archive/2013/02/16/where-did-all-my-gestures-go.aspx#comments</comments><description>&lt;p&gt;A common problem we’ve seen from customers is how to handle pointer input and manipulations on elements inside of collection controls such as ListViews, GridViews, and FlipViews. The app can get the PointerPressed event on items inside the View, but after that the pointer events disappear and the app cannot convert them into gestures or manipulations.&lt;/p&gt;  &lt;p&gt;So what is going on here?&lt;/p&gt;  &lt;p&gt;The common element is that these controls all host a ScrollViewer, and the ScrollViewer takes over the pointer handling to run its scrolling. Once the ScrollViewer is in charge it handles all of the pointer and manipulation events without the app having its own chance at them.&lt;/p&gt;  &lt;p&gt;This means that if an app needs to handle pointer events inside a scrolling control then it needs to disable the ScrollViewer (more on that below).&lt;/p&gt;  &lt;p&gt;Why does the ScrollViewer take over the pointer handling?&lt;/p&gt;  &lt;p&gt;Efficiency and responsiveness. Xaml applications compose and render their graphics on separate threads. The rendering thread is in charge of keeping the screen updating at a fluid pace. The composition thread is where the app’s UI code runs and which can update the layout of the controls. Whenever the layout isn’t updating the render thread can keep the visual display crisp and quick even while other work is being done. Non-layout updates such as independent animations and rendering transforms can be done on the rendering thread without slowing down to synchronize the two threads.&lt;/p&gt;  &lt;p&gt;Because touch manipulations need to be very responsive, Xaml apps tap into a Windows feature known as &lt;a href="http://msdn.microsoft.com/en-us/library/windows/desktop/hh446969(v=vs.85).aspx"&gt;Direct Manipulation&lt;/a&gt; to handle input at a low level on the render thread. Direct Manipulation detects touch input such as scrolling, panning, and scaling. The ScrollViewer uses it to scroll swiftly and cleanly, and the app can listen to Direct Manipulation via the Xaml Manipulation events to apply scaling, translation, and rotation render transforms responsively in sync with the render thread.&lt;/p&gt;  &lt;p&gt;That is where the missing pointer events go. When the ScrollViewer handles the PointerPressed event the Direct Manipulation engine takes over the pointer handling and the app doesn’t receive any more pointer events until the current manipulation has ended.&lt;/p&gt;  &lt;p&gt;So what can an app do if it needs the pointer messages?&lt;/p&gt;  &lt;p&gt;The easiest way is to restrict the needed pointer messages to a sub-item which blocks the scrolling and set it to handle its own manipulations. For example, an Image in a FlipView’s ItemTemplate with ManipulationMode=”All” will not trigger the ScrollViewer for touches inside the image. The Image will receive both Xaml manipulation events and pointer events which can be passed to a GestureRecognizer.&lt;/p&gt;  &lt;p&gt;If the app cannot scope the pointer messages to a sub-item then it is trickier. The next best is to restrict the messages to a sub-region or usage mode. In that case the PointerPressed handler can detect if it is in the sub-region or non-scrolling mode, and if so it can walk the visual tree to find the ScrollViewer and disable the ScrollViewer’s invocation of Direct Manipulation. To do this, change the ScrollViewer’s HorizontalScrollMode and VerticalScrollMode to Disabled. Likely you’ll only need to change one, depending on if you have a horizontally scrolling GridView or FlipView, or a vertically scrolling ListView:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;ScrollViewer FindParentScrollViewer(DependencyObject start)      &lt;br /&gt; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; DependencyObject item = start;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; DependencyObject parent = null;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; do       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; parent = (DependencyObject)VisualTreeHelper.GetParent(item);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (parent is ScrollViewer)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return parent as ScrollViewer;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; item = parent;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } while (item != null);&lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; return null;      &lt;br /&gt;}&lt;/p&gt;    &lt;p&gt;&amp;#160;&lt;/p&gt;    &lt;p&gt;bool InDisableScrollViewerRegion(PointerPoint pt)      &lt;br /&gt; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // For demonstration purposes, scroll at the top and block the rest       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; return pt.Position.Y &amp;gt; 400;       &lt;br /&gt; }&lt;/p&gt;    &lt;p&gt;private void OnPointerPressed(object sender, PointerRoutedEventArgs e)      &lt;br /&gt; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; DependencyObject depObj = (DependencyObject)e.OriginalSource;       &lt;br /&gt;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if (InDisableScrollViewerRegion(e.GetCurrentPoint(this)))       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DisableScrolling((DependencyObject)e.OriginalSource);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; UIElement target = sender as UIElement;&lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; PointerPoint point = e.GetCurrentPoint(itemFlipView);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; gestureRecognizer.ProcessDownEvent(point);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; target.CapturePointer(e.Pointer);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; e.Handled = true;       &lt;br /&gt; } &lt;/p&gt;    &lt;p&gt;ScrollMode _originalScrollMode;     &lt;br /&gt;bool _scrollingDisabled = false;      &lt;br /&gt;private void DisableScrolling(DependencyObject depObj)      &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ScrollViewer parentElem;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; parentElem = FindParentScrollViewer(depObj);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (parentElem != null)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _originalScrollMode = parentElem.HorizontalScrollMode;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _scrollingDisabled = true;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; parentElem.HorizontalScrollMode = ScrollMode.Disabled;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;}&lt;/p&gt;    &lt;p&gt;private void RestoreScrolling(DependencyObject depObj)     &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (_scrollingDisabled)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _scrollingDisabled = false;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ScrollViewer parentElem = FindParentScrollViewer(depObj);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (parentElem != null)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; parentElem.HorizontalScrollMode = _originalScrollMode;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt; }&lt;/p&gt;    &lt;p&gt;&amp;#160;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Unfortunately there is no good solution if the app needs both scrolling and gestures (for example, to detect CrossSlides against the scrolling). In this case the only option to get the Pointer messages everywhere is to disable Direct Manipulation everywhere, but that disables scrolling as well. To get that back the app will need to detect the scrolling gestures itself and then navigate the ScrollViewer to the new location with ScrollToHorizontalOffset or ScrollToVerticalOffset or by updating the SelectedIndex. This is tricky and will be noticeably slower than letting the ScrollViewer do its thing. It should be avoided if at all possible.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;--Rob&lt;/p&gt;  &lt;p&gt;Follow us on Twitter @wsdevsol!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10394216" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/_2300_WSDevSol/">#WSDevSol</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/XAML/">XAML</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Windows+8/">Windows 8</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Windows+Store+apps/">Windows Store apps</category><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/ScrollViewer/">ScrollViewer</category></item><item><title>How to use HttpClient to post JSON data</title><link>http://blogs.msdn.com/b/wsdevsol/archive/2013/02/05/how-to-use-httpclient-to-post-json-data.aspx</link><pubDate>Tue, 05 Feb 2013 19:43:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10391322</guid><dc:creator>Jeff  Sanders</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/wsdevsol/rsscomments.aspx?WeblogPostID=10391322</wfw:commentRss><comments>http://blogs.msdn.com/b/wsdevsol/archive/2013/02/05/how-to-use-httpclient-to-post-json-data.aspx#comments</comments><description>&lt;p&gt;This is a common request in forums so I will show you how to use the new HttpClient class and the DataContractJsonSerializer to post JSON data to a web service.&amp;#160; Posting serialized JSON objects to web endpoints is a common way to get data over HTTP and HTTPS to and end point and although this is extremely easy in the WinJS realm (when writing HTML5/JavaScript Windows Store apps), there is not a good example of how to do this using HttpClient for the .NET applications.&amp;#160; &lt;/p&gt;  &lt;h2&gt;Step 1 – Find out what data you need to send&lt;/h2&gt;  &lt;p&gt;If you are sending JSON data to a WebService the service itself should have an example of what it expects.&amp;#160; Often there is sample code that you can use to generate a POST.&amp;#160; Start by capturing a successful POST to the web service and capture the HTTP or HTTPS traffic.&amp;#160; This will allow you to compare your POST to something you know is correct.&amp;#160; One tool that will help you immensely while developing apps using HTTP and HTTPS protocols is &lt;a href="http://fiddler2.com" target="_blank"&gt;Fiddler&lt;/a&gt;.&amp;#160; In my sample I captured the HTTP traffic to a &lt;a href="http://www.windowsazure.com/en-us/home/scenarios/mobile-services/" target="_blank"&gt;Windows Azure Mobile Services&lt;/a&gt; endpoint.&amp;#160; &lt;/p&gt;  &lt;p&gt;Here is the HTTP traffic I captured with Fiddler from the sample application generated by Mobile Services when I POST data to the background database.&lt;/p&gt;  &lt;p&gt;POST &lt;a href="https://sharemydata.azure-mobile.net/tables/TodoItem"&gt;https://sharemydata.azure-mobile.net/tables/TodoItem&lt;/a&gt; HTTP/1.1     &lt;br /&gt; Accept: application/json     &lt;br /&gt; X-ZUMO-INSTALLATION-ID: 8bc6aea9-864a-44fc-9b4b-87ec64e123bd     &lt;br /&gt; X-ZUMO-APPLICATION: OabcWgaGVdIXpqwbMTdBQcxyrOpeXa20     &lt;br /&gt; Content-Type: application/json     &lt;br /&gt; Host: sharemydata.azure-mobile.net     &lt;br /&gt; Content-Length: 31     &lt;br /&gt; Expect: 100-continue&lt;/p&gt;  &lt;p&gt;{&amp;quot;text&amp;quot;:&amp;quot;ddd&amp;quot;,&amp;quot;complete&amp;quot;:false}&lt;/p&gt;  &lt;p&gt;Instead of using the magic of the MobileServices classes provided, In the next step I will show how to use the new HttpClient classes to show how to POST the same data I captured above.&amp;#160; You should then be able to extend this to your case when you need to POST using JSON.&amp;#160; Again the intent is not to bypass the libraries we have provided for you, simply show how one JSON based web service can be analyzed and you can use this to troubleshoot and POST to it using the HttpClient and associated classes.&lt;/p&gt;  &lt;h2&gt;Step 2 – Understand what is being POSTED and duplicate it&lt;/h2&gt;  &lt;p&gt;Let’s walk through the trace I took above line by line and create code to duplicate this:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;POST &lt;/strong&gt;&lt;a href="https://sharemydata.azure-mobile.net/tables/TodoItem"&gt;&lt;strong&gt;https://sharemydata.azure-mobile.net/tables/TodoItem&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; HTTP/1.1&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;// I will create an HttpClient and POST to the Uri &lt;a href="https://sharemydata.azure-mobile.net/tables/TodoItem"&gt;https://sharemydata.azure-mobile.net/tables/TodoItem&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;// Create HttpClient instance to use for the app    &lt;br /&gt;HttpClient aClient = new HttpClient();&lt;/p&gt;  &lt;p&gt;// Uri is where we are posting to:    &lt;br /&gt; Uri theUri = new Uri(&amp;quot;&lt;a href="https://sharemydata.azure-mobile.net/tables/TodoItem&amp;quot;);"&gt;&lt;font style="background-color: rgb(255, 255, 0);"&gt;https://sharemydata.azure-mobile.net/tables/TodoItem&lt;/font&gt;&amp;quot;);&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;// use the Http client to POST some content ( ‘theContent’ not yet defined).    &lt;br /&gt;aClient.&lt;font style="background-color: rgb(255, 255, 0);"&gt;Post&lt;/font&gt;Async(theUri, theContent);&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Accept: application/json&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;// I have to let the server know I accept json data when it replies so this will add that header&lt;/p&gt;  &lt;p&gt;aClient.DefaultRequestHeaders.&lt;font style="background-color: rgb(255, 255, 0);"&gt;Accept&lt;/font&gt;.Add(new MediaTypeWithQualityHeaderValue(&amp;quot;&lt;font style="background-color: rgb(255, 255, 0);"&gt;application/json&lt;/font&gt;&amp;quot;));&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;X-ZUMO-INSTALLATION-ID: 8bc6aea9-864a-44fc-9b4b-87ec64e123bd&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I saw from the webservice documentation this is optional so I could leave it out (but I won’t).&lt;/p&gt;  &lt;p&gt;aClient.DefaultRequestHeaders.Add(&amp;quot;&lt;font style="background-color: rgb(255, 255, 0);"&gt;X-ZUMO-INSTALLATION-ID&lt;/font&gt;&amp;quot;, &amp;quot;&lt;font style="background-color: rgb(255, 255, 0);"&gt;8bc6aea9-864a-44fc-9b4b-87ec64e123bd&lt;/font&gt;&amp;quot;);&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;X-ZUMO-APPLICATION: OabcWgaGVdIXpqwbMTdBQcxyrOpeXa20&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Set this header to let the service know what application is trying to insert data&lt;/p&gt;  &lt;p&gt;aClient.DefaultRequestHeaders.Add(&amp;quot;&lt;font style="background-color: rgb(255, 255, 0);"&gt;X-ZUMO-APPLICATION&lt;/font&gt;&amp;quot;,&amp;quot;&lt;font style="background-color: rgb(255, 255, 0);"&gt;OabcWgaGVdIXpqwbMTdBQcxyrOpeXa20&lt;/font&gt;&amp;quot;);&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Host: &lt;font style="background-color: rgb(255, 255, 0);"&gt;sharemydata.azure-mobile.net&lt;/font&gt; &lt;/strong&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;aClient.DefaultRequestHeaders.Host = &lt;font style="background-color: rgb(255, 255, 0);"&gt;theUri.Host&lt;/font&gt;;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Expect: 100-continue&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;This is added by default so you do not have to do anything&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Content headers and information&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You will notice I skipped&amp;#160; Content-Type: application/json, Content-Length: 31 and {&amp;quot;text&amp;quot;:&amp;quot;ddd&amp;quot;,&amp;quot;complete&amp;quot;:false}.&lt;/p&gt;  &lt;p&gt;All this is content related will be added by assigning ‘theContent’ as a StringContent object in the PostAsync call above.&amp;#160; You can certainly send simple text and format it yourself to be a JSON string and this is fine for simple JSON posts.&amp;#160; If you have a complicated object it is better to let our classes do the work for you!&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Define a class that reflects the JSON data posted.&lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;[DataContract]      &lt;br /&gt;&amp;#160;&amp;#160; public class TodoItem2       &lt;br /&gt;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public int Id { get; set; }&lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [DataMember(Name = &amp;quot;text&amp;quot;)]      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string Text { get; set; }&lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [DataMember(Name = &amp;quot;complete&amp;quot;)]      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public bool Complete { get; set; }       &lt;br /&gt;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p&gt;Here I defined a class to represent the JSON data I will post.&amp;#160; The attributes ‘DataContract’ and ‘DataMember’ are necessary for the JSON serialization class.&amp;#160; You will see that ‘DataMember’ further defines the name ‘text’ and ‘complete’ which are lower case representations of the public members of the class.&amp;#160; This illustrates that you can adorn and existing class and change the Name of the DataMember used to generate the serialized JSON data.&amp;#160; Also notice that the public int ‘Id’ does not have a DataMember attribute.&amp;#160; This will hide this attribute from the serialization.&lt;/p&gt; &lt;/blockquote&gt;  &lt;ul&gt;   &lt;li&gt;Create and Populate the class with data&lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;You simply instantiate and assign the data to the is class:&lt;/p&gt;    &lt;p&gt;//Class that will be serialized into Json and posted&lt;/p&gt;    &lt;p&gt; TodoItem2 todoItem2 = new TodoItem2();&lt;/p&gt;    &lt;p&gt;//Set some values      &lt;br /&gt; todoItem2.Text = &amp;quot;ddd&amp;quot;;       &lt;br /&gt;todoItem2.Complete = false;       &lt;br /&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;ul&gt;   &lt;li&gt;Add code to serialize the object to a string and create a StringContent object to pass to the PostAsync call&lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;//Create a Json Serializer for our type      &lt;br /&gt;DataContractJsonSerializer jsonSer = new DataContractJsonSerializer(typeof(TodoItem2));&lt;/p&gt;    &lt;p&gt;// use the serializer to write the object to a MemoryStream      &lt;br /&gt;MemoryStream ms = new MemoryStream();       &lt;br /&gt;jsonSer.WriteObject(&amp;#160; ms, todoItem2);&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;ms.Position = 0;&lt;/p&gt;    &lt;p&gt;//use a Stream reader to construct the StringContent (Json)      &lt;br /&gt;StreamReader sr = new StreamReader(ms);       &lt;br /&gt;StringContent theContent = new StringContent(sr.ReadToEnd(), System.Text.Encoding.UTF8,&amp;quot;application/json&amp;quot;);&lt;/p&gt;    &lt;p&gt;&amp;#160;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h2&gt;Step 3 – Validate your POST looks correct and works&lt;/h2&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;This is all you need to do in order to stream the content of the object to the web service.&amp;#160; Now when I run this code in my app and take a trace with Fiddler I see that the POST succeeded with a 201 and the POST indeed is practically identical to my previous successful case (the order of the headers is different and there is a charset attached to the Content-Type which is fine):&lt;/p&gt;  &lt;p&gt;POST &lt;a href="https://sharemydata.azure-mobile.net/tables/TodoItem"&gt;https://sharemydata.azure-mobile.net/tables/TodoItem&lt;/a&gt; HTTP/1.1     &lt;br /&gt; Accept: application/json     &lt;br /&gt; X-ZUMO-INSTALLATION-ID: 8bc6aea9-864a-44fc-9b4b-87ec64e123bd     &lt;br /&gt; X-ZUMO-APPLICATION: OabcWgaGVdIXpqwbMTdBQcxyrOpeXa20     &lt;br /&gt; Content-Type: application/json; charset=utf-8     &lt;br /&gt; Host: sharemydata.azure-mobile.net     &lt;br /&gt; Content-Length: 31     &lt;br /&gt; Expect: 100-continue     &lt;br /&gt; Connection: Keep-Alive&lt;/p&gt;  &lt;p&gt;{&amp;quot;complete&amp;quot;:false,&amp;quot;text&amp;quot;:&amp;quot;ddd&amp;quot;}&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;If you realize that POSTing JSON data is simply providing the correct HTTP or HTTPS traffic to an endpoint, you can use the above code to build your own code that will communicate with whatever endpoint you want.&amp;#160; You are really just sending a string with the appropriate headers.&amp;#160; Receiving JSON data is similar and will be covered in a following POST if there is enough interest (however it is fairly well documented).&lt;/p&gt;  &lt;p&gt;Follow us on Twitter @wsdevsol!&lt;/p&gt;  &lt;p&gt;Note:&amp;#160; I changed the data in this post to a fictional end point.&amp;#160; You will need to create your own Windows Azure Mobile Services application to try this yourself or identify your own endpoint that accepts JSON data! &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Completed Code:&lt;/h2&gt;  &lt;h3&gt;C#&lt;/h3&gt;  &lt;p&gt;[DataContract]    &lt;br /&gt;&amp;#160;&amp;#160; public class TodoItem2     &lt;br /&gt;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public int Id { get; set; }&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [DataMember(Name = &amp;quot;text&amp;quot;)]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string Text { get; set; }&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [DataMember(Name = &amp;quot;complete&amp;quot;)]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public bool Complete { get; set; }     &lt;br /&gt;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;p&gt;//Where we are posting to:    &lt;br /&gt; Uri theUri = new Uri(&amp;quot;&lt;a href="https://sharemydata.azure-mobile.net/tables/TodoItem&amp;quot;);"&gt;https://sharemydata.azure-mobile.net/tables/TodoItem&amp;quot;);&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;//Create an Http client and set the headers we want    &lt;br /&gt;HttpClient aClient = new HttpClient();     &lt;br /&gt;aClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(&amp;quot;application/json&amp;quot;));     &lt;br /&gt;aClient.DefaultRequestHeaders.Add(&amp;quot;X-ZUMO-INSTALLATION-ID&amp;quot;, &amp;quot;8bc6aea9-864a-44fc-9b4b-87ec64e123bd&amp;quot;);     &lt;br /&gt;aClient.DefaultRequestHeaders.Add(&amp;quot;X-ZUMO-APPLICATION&amp;quot;, &amp;quot;OabcWgaGVdIXpqwbMTdBQcxyrOpeXa20&amp;quot;);     &lt;br /&gt;aClient.DefaultRequestHeaders.Host = theUri.Host;&lt;/p&gt;  &lt;p&gt;//Class that will be serialized into Json and posted    &lt;br /&gt; TodoItem2 todoItem2 = new TodoItem2();&lt;/p&gt;  &lt;p&gt;//Set some values    &lt;br /&gt; todoItem2.Text = &amp;quot;ddd&amp;quot;;     &lt;br /&gt; todoItem2.Complete = false;&lt;/p&gt;  &lt;p&gt;//Create a Json Serializer for our type    &lt;br /&gt;DataContractJsonSerializer jsonSer = new DataContractJsonSerializer(typeof(TodoItem2));&lt;/p&gt;  &lt;p&gt;// use the serializer to write the object to a MemoryStream    &lt;br /&gt;MemoryStream ms = new MemoryStream();     &lt;br /&gt;jsonSer.WriteObject(ms, todoItem2);     &lt;br /&gt;ms.Position = 0;&lt;/p&gt;  &lt;p&gt;//use a Stream reader to construct the StringContent (Json)    &lt;br /&gt;StreamReader sr = new StreamReader(ms);     &lt;br /&gt; // Note if the JSON is simple enough you could ignore the 5 lines above that do the serialization and construct it yourself     &lt;br /&gt; // then pass it as the first argument to the StringContent constructor     &lt;br /&gt;StringContent theContent = new StringContent(sr.ReadToEnd(), System.Text.Encoding.UTF8, &amp;quot;application/json&amp;quot;);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt; //Post the data     &lt;br /&gt;HttpResponseMessage aResponse = await aClient.PostAsync(theUri, theContent);&lt;/p&gt;  &lt;p&gt;if (aResponse.IsSuccessStatusCode)    &lt;br /&gt; {&lt;/p&gt;  &lt;p&gt;}    &lt;br /&gt; else     &lt;br /&gt; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // show the response status code     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; String failureMsg = &amp;quot;HTTP Status: &amp;quot; + aResponse.StatusCode.ToString() + &amp;quot; - Reason: &amp;quot; + aResponse.ReasonPhrase;     &lt;br /&gt;}     &lt;br /&gt;&lt;/p&gt;  &lt;h3&gt;VB&lt;/h3&gt;  &lt;p&gt;Public Class TodoItem2   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Private Property Id() As Integer    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Get    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Return m_Id    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End Get    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Set(value As Integer)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; m_Id = value    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End Set    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End Property    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Private m_Id As Integer&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Public Property Text() As String    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Get    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Return m_Text    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End Get    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Set(value As String)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; m_Text = value    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End Set    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End Property    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Private m_Text As String&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Public Property Complete() As Boolean    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Get    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Return m_Complete    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End Get    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Set(value As Boolean)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; m_Complete = value    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End Set    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End Property    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Private m_Complete As Boolean    &lt;br /&gt; End Class&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Private Async Sub SendJsonPost()   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; 'Where we are posting to:     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Dim theUri As New Uri(&amp;quot;&lt;a href="https://sharemydata.azure-mobile.net/tables/TodoItem&amp;quot;)"&gt;https://sharemydata.azure-mobile.net/tables/TodoItem&amp;quot;)&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; 'Create an Http client and set the headers we want    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Dim aClient As New HttpClient()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; aClient.DefaultRequestHeaders.Accept.Add(New MediaTypeWithQualityHeaderValue(&amp;quot;application/json&amp;quot;))    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; aClient.DefaultRequestHeaders.Add(&amp;quot;X-ZUMO-INSTALLATION-ID&amp;quot;, &amp;quot;8bc6aea9-864a-44fc-9b4b-87ec64e123bd&amp;quot;)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; aClient.DefaultRequestHeaders.Add(&amp;quot;X-ZUMO-APPLICATION&amp;quot;, &amp;quot;OabcWgaGVdIXpqwbMTdBQcxyrOpeXa20&amp;quot;)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; aClient.DefaultRequestHeaders.Host = theUri.Host&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; 'Class that will be serialized into Json and posted    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Dim todoItem2 As New TodoItem2()&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; 'Set some values    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; todoItem2.Text = &amp;quot;ddd&amp;quot;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; todoItem2.Complete = False&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; 'Create a Json Serializer for our type   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Dim jsonSer As New DataContractJsonSerializer(GetType(TodoItem2))&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; ' use the serializer to write the object to a MemoryStream    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Dim ms As New MemoryStream()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; jsonSer.WriteObject(ms, todoItem2)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ms.Position = 0    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Dim sr As New StreamReader(ms)&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; 'Note if the JSON is simple enough you could ignore the 5 lines above that do the serialization and construct it yourself    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; 'then pass it as the first argument to the StringContent constructor     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Dim theContent As New StringContent(sr.ReadToEnd(), System.Text.Encoding.UTF8, &amp;quot;application/json&amp;quot;)&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; 'Post the data    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Dim aResponse As HttpResponseMessage = Await aClient.PostAsync(theUri, theContent)&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; If (aResponse.IsSuccessStatusCode) Then&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; Else&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 'show the response status code   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Dim failureMsg = &amp;quot;HTTP Status: &amp;quot; + aResponse.StatusCode.ToString() + &amp;quot; - Reason: &amp;quot; + aResponse.ReasonPhrase&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; End If   &lt;br /&gt; End Sub    &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10391322" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/wsdevsol/archive/tags/Windows+Azure+Mobile+Services/">Windows Azure Mobile Services</category></item></channel></rss>