<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Windows Azure Technical Forum Support Team Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/windows-azure-support/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/windows-azure-support/feed.xml</link>
    <description>Blog hosted by Microsoft Windows Azure Tech Forum Support Team, provides tech support of Windows Azure, SQL Azure, Appfabric…</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:30:04 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Please post questions on the forums</title>
      <link>https://docs.microsoft.com/archive/blogs/windows-azure-support/please-post-questions-on-the-forums</link>
      <pubDate>Thu, 24 Feb 2011 21:47:49 GMT</pubDate>
      <dc:creator><![CDATA[China Windows Azure Blog]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/windows-azure-support/2011/02/24/please-post-questions-on-the-forums/</guid>
      <description><![CDATA[Recently our team received several emails asking questions about Windows 
Azure Platform. We...]]></description>
      <content:encoded><![CDATA[<p>
<p>Recently our team received several emails asking questions about Windows 
Azure Platform. We welcome your questions, and we're glad to help you. But we'd 
like to state that before sending emails to our team, it is recommended to post 
the question on the
<a href="https://social.msdn.microsoft.com/Forums/en-US/category/windowsazureplatform/">
forums</a>. Below we'll list several benefits you'll get by posting the question 
on the forums:</p>
<ol>
<li>The question is more visible, and more community members will help you 
	to solve the problem.</li>
<li>You can search the forums first to find similar problems, and how they 
	were solved.</li>
<li>Our team does not work 24*7. But when we're sleeping, very likely a 
	community member in the other half of the hemisphere will answer your 
	question.</li>
<li>If your question is answered, the answer will become a valuable piece of 
	knowledge for other community members.</li>
</ol>
<p>We call our work on the technical forums as community support. So we'd like 
to share our knowledge with as many as community members as possible. But we 
also understand from time to time, you may encounter situations that you do not 
want to share with others. In this case, please feel free to contact other 
support channels as listed on
<a href="https://www.microsoft.com/windowsazure/support/">
https://www.microsoft.com/windowsazure/support/</a>. Currently all supports are 
free of charge.</p>
</p>]]></content:encoded>
    </item>
    <item>
      <title>Azure + Bing Maps: Sample source code and updated live demonstration now available</title>
      <link>https://docs.microsoft.com/archive/blogs/windows-azure-support/azure-bing-maps-sample-source-code-and-updated-live-demonstration-now-available</link>
      <pubDate>Wed, 26 Jan 2011 22:40:28 GMT</pubDate>
      <dc:creator><![CDATA[China Windows Azure Blog]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/windows-azure-support/2011/01/26/azure-bing-maps-sample-source-code-and-updated-live-demonstration-now-available/</guid>
      <description><![CDATA[We're happy to announce the source code for the Azure + Bing Maps sample is now available on 1Code....]]></description>
      <content:encoded><![CDATA[<p>We're happy to announce the source code for the Azure + Bing Maps sample is now available on 1Code. You can download the C# version from <a href="https://1code.codeplex.com/releases/view/59639#DownloadId=201758">https://1code.codeplex.com/releases/view/59639#DownloadId=201758</a>, and the VB version from <a href="https://1code.codeplex.com/releases/view/59639#DownloadId=201818">https://1code.codeplex.com/releases/view/59639#DownloadId=201818</a>. Note to build and run the sample, you must provide your own account information, such as Windows Azure, SQL Azure, AppFabric, Bing Maps, Windows Live Messenger Connect, etc. Please refer to the ReadMe.htm in the downloaded package for more instructions.</p>
<p>In addition, the live demonstration has also been updated to reflect the latest changes. You can find the new HTML client demo on <a href="https://azurebingmaps.cloudapp.net/HtmlClient.aspx">https://azurebingmaps.cloudapp.net/HtmlClient.aspx</a> (best to view in IE9), and the Silverlight client demo on <a href="https://azurebingmaps.cloudapp.net/SilverlightClient.aspx">https://azurebingmaps.cloudapp.net/SilverlightClient.aspx</a>. There's no live demonstration for the Windows Phone client, so you'll have to download the source code, provide your own account information, and build the Windows Phone client project.</p>
<p>By the way, if you don't know the 1Code project, it is a central place for Microsoft to ship code and application samples. It contains more than 500 samples (and more to come in the future), which covers almost (if not all) Microsoft development areas. There're small code samples demonstrating single how to topics, as well as large application samples like ours combined with blog post series demonstrating how to build a complete project. All samples are free to download. Feel free to check out the 1Code site on <a href="https://1code.codeplex.com/">https://1code.codeplex.com/</a>.</p>]]></content:encoded>
    </item>
    <item>
      <title>Azure + Bing Maps: Creating a Windows Phone Client</title>
      <link>https://docs.microsoft.com/archive/blogs/windows-azure-support/azure-bing-maps-creating-a-windows-phone-client</link>
      <pubDate>Thu, 23 Dec 2010 23:39:00 GMT</pubDate>
      <dc:creator><![CDATA[China Windows Azure Blog]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/windows-azure-support/2010/12/23/azure-bing-maps-creating-a-windows-phone-client/</guid>
      <description><![CDATA[&nbsp;
This is the 12th article in our "Bring the clouds together: Azure + Bing Maps"...]]></description>
      <content:encoded><![CDATA[<p>&nbsp;</p>
<p>This is the 12th article in our "Bring the clouds together: Azure + Bing Maps" 
        series. You can find a preview of live demonstration on
        <a href="https://sqlazurebingmap.cloudapp.net/">
        https://sqlazurebingmap.cloudapp.net/</a>. For a list of articles in the series, 
        please refer to <a href="https://blogs.msdn.com/b/windows-azure-support/archive/2010/08/11/bring-the-clouds-together-azure-bing-maps.aspx">https://blogs.msdn.com/b/windows-azure-support/archive/2010/08/11/bring-the-clouds-together-azure-bing-maps.aspx</a>.</p>
<h3>
        Introduction</h3>
<p>
        In our previous post, we created a Silverlight client which accesses our 
		cloud service, and verified the service doesn't need to be modified to 
		support the new client. Actually till now, our solution is complete. But 
		for your reference, we decided to add a Windows Phone client (as this is 
		a hot topic now) to our solution. It is basically similar to the 
		Silverlight client, although to fit a small screen, the layout has been 
		redesigned.</p>
<h3>
        Choose Silverlight or XNA</h3>
<p>
        Windows Phone supports both Silverlight and XNA. The choice is often 
		very simple. XNA is used for game development. It doesn't provide any UI 
		elements (such as controls). It doesn't have framework like layout and 
		data binding. But it provides a built-in game loop. Silverlight can also 
		be used to develop games, although you must be aware that putting too 
		many UI elements on the screen (as games usually do) can be inefficient. 
		In addition, Silverlight only supports perspective 3D, that is, rotate a 
		2D plain in the 3D space. For full 3D support, you have to use XNA.</p>
<p>
        Both Silverlight and XNA can talk to SOAP/REST services, and the code is 
		exactly the same.</p>
<p>
        Our application is not a game. It does not require full 3D. And we have 
		already created a desktop Silverlight client. So we'll choose 
		Silverlight. As you'll find later, most code from our desktop 
		Silverlight application can be reused. But there're still a few 
		differences, as pointed out in the following sections.</p>
<h3>
        Layout and page navigation for Windows Phone</h3>
<p>
        A Windows Phone device's screen resolution is 800*480 or 480*800, 
		depending on the phone's orientation. This is significantly smaller 
		compared to a PC screen. So we cannot present too much information on a 
		single page in a Windows Phone application.</p>
<p>
        Our application needs to display a map as well as a list. So it makes 
		sense to use 2 pages, and provide a mechanism to navigate between the 
		two pages. There're several standard ways to navigate between pages.</p>
<p>
        The most commonly used solution for page navigation is to handle the 
		Flick gesture, check if the user flicks (moves the finger very fast) 
		horizontally, and navigate back/forward. You can learn about gestures 
		from
		<a href="https://msdn.microsoft.com/en-us/library/ff967546(VS.92).aspx">
		https://msdn.microsoft.com/en-us/library/ff967546%28VS.92%29.aspx</a>. 
		Unfortunately, Bing Maps Windows Phone control already handles gestures. 
		If we also handle the gestures, if the user pans the map in the 
		horizontal direction very quickly, the result will be a page navigation 
		rather than a map panning.</p>
<p>
        So we have to fallback to a more traditional solution. We'll provide a 
		button for page navigation. But instead of using a standard Silverlight 
		button, let's use Windows Phone's application bar. The application bar 
		always stays at the bottom of the screen, so we don't have to manually 
		layout the button.</p>
<p>
        To put a button in the application bar, use the following markup:</p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp; </span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">
&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">phone</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">PhoneApplicationPage.ApplicationBar</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">
&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">shell</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">ApplicationBar</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> 
IsVisible</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="True"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> 
IsMenuEnabled</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="True"&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">
&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">shell</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">ApplicationBarIconButton</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> 
IconUri</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="appbar.next.rest.png"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> 
Text</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="Stops 
List"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> 
Click</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="ApplicationBarIconButton_Click"/&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">
&lt;/</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">shell</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">ApplicationBar</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp; </span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">
&lt;/</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">phone</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">PhoneApplicationPage.ApplicationBar</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p>
        Note all buttons in the application bar must contain an icon, which must 
		be a bitmap. If you're a developer but not a designer, you can use 
		standard icons shipped with Windows Phone SDK (as we do in our case). 
		You can the standard icons under Program Files (x86)\Microsoft 
		SDKs\Windows Phone\v7.0\Icons.</p>
<p>
        The next step is of course handle the Click event of the button, and 
		perform page navigation. This can be done using 
		NavigationService.Navigate.</p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="color: blue;">private</span> <span style="color: blue;">void</span> 
ApplicationBarIconButton_Click(<span style="color: blue;">object</span> sender,
<span style="color: #2b91af;">EventArgs</span> e)</span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span>{</span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="color: blue;">this</span>.NavigationService.Navigate(<span style="color: blue;">new</span>
<span style="color: #2b91af;">Uri</span>(<span style="color: #a31515;">"/ListPage.xaml"</span>,
<span style="color: #2b91af;">UriKind</span>.Relative));</span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span>}</span></p>
<p>
        When running in the emulator, the result is below:</p>
<p>
        <img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/39/79/0842.MainPage.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-39-79/0842.MainPage.jpg" border="0" /></p>
<p>
        After you click the button using either mouse or finger, you'll be 
		redirected to the list page:</p>
<p>
        <img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/39/79/4812.ListPage.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-39-79/4812.ListPage.jpg" border="0" /></p>
<p>
        Similarly, you can define another button on the list page, and use the 
		same logic to navigate the user back to the map page.&nbsp;</p>
<h3>
        Using Bing Maps Silverlight Control in Windows Phone</h3>
<p>
        Using Windows Phone Bing Maps Silverlight control is similar to using 
		the desktop Bing maps Silverlight control, at least conceptually. But 
		there're several differences. We'll examine the similarity and 
		difference below:</p>
<p>
        First, the control is defined in different assemblies.</p>
<p>
        Desktop version:</p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun;">
<span style="color: red;">
xmlns</span><span style="color: blue;">:</span><span style="color: red;">Microsoft_Maps_MapControl</span><span style="color: blue;">="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"</span></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun;">
<span style="color: red;">
xmlns</span><span style="color: blue;">:</span><span style="color: red;">Microsoft_Maps_MapControl_Common</span><span style="color: blue;">="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl.Common"</span></span></p>
<p>
        Windows Phone version:</p>
<p>
        <span style="font-size: 9.5pt; line-height: 115%; font-family: NSimSun; color: red;">xmlns</span><span style="font-size: 9.5pt; line-height: 115%; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; line-height: 115%; font-family: NSimSun; color: red;">Microsoft_Phone_Controls</span><span style="font-size: 9.5pt; line-height: 115%; font-family: NSimSun; color: blue;">="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"</span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: red;">xmlns</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;">System_Device_Location</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="clr-namespace:System.Device.Location;assembly=System.Device"</span></p>
<p>
        The phone has location information support built-in, so Bing Maps does 
		not need to provide its own implementation of location service.</p>
<p>
        Second, displaying the map is almost the same as the desktop version. 
		For your reference:</p>
<p>
        Desktop version:</p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Maps_MapControl</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Map</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> x</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;">Name</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="map"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Margin</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="8,21,36,23"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Loaded</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="Map_Loaded"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> ZoomLevel</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="4"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> MouseClick</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="map_MouseClick"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> d</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;">LayoutOverrides</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="GridBox"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Grid.Column</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="1"&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Maps_MapControl</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Map.Center</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Maps_MapControl_Common</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Location</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> AltitudeReference</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="Ground"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Altitude</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="0"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Longitude</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="121"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Latitude</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="31"/&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;/</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Maps_MapControl</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Map.Center</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Maps_MapControl</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">MapItemsControl</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> x</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;">Name</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="mapItems"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> ItemTemplate</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="{</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">StaticResource</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> MapItemDataTemplate</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">}"/&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
</span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;/</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Maps_MapControl</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Map</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p>
        Windows Phone version:&nbsp;</p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
</span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Phone_Controls</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Map</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> x</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;">Name</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="map"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Loaded</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="Map_Loaded"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> ZoomLevel</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="6"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Margin</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="0,0,-12,0"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> MouseLeftButtonDown</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="map_MouseLeftButtonDown"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> MouseLeftButtonUp</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="map_MouseLeftButtonUp"&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Phone_Controls</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Map.Center</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">System_Device_Location</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">GeoCoordinate</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Altitude</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="0"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Latitude</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="31"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Longitude</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="121"/&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;/</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Phone_Controls</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Map.Center</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Phone_Controls</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">MapItemsControl</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> x</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;">Name</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="mapItems"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> ItemTemplate</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="{</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">StaticResource</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> MapItemDataTemplate</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">}"/&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;/</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Phone_Controls</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Map</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p>
        The noteable difference is the type Location is not a Bing Maps specific 
		type on Windows Phone. This type can be used in other scenarios (such as 
		GPS locating) as well.</p>
<p>
        Third, as shown above, displaying a list of pushpins is exactly the same 
		as desktop version. You create a MapItemsControl and bind it to a data 
		source. However, the Pushpin control has somewhat different properties. 
		As you can see below, on desktop, there's a Position property, while on 
		the phone, the property is named Location.</p>
<p>
        Desktop version:</p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">DataTemplate</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> x</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;">Key</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="MapItemDataTemplate"&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp; </span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Maps_MapControl</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Pushpin</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Cursor</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="Hand"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Content</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="{</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Binding</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Place</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">}"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> 
Microsoft_Maps_MapControl</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;">MapLayer.Position</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="{</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Binding</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Converter</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">={</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">StaticResource</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> locationConverter</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">}}"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Template</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="{</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">StaticResource</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> PushpinControlTemplate</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">}"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Style</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="{</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">StaticResource</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> PushpinStyle</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">}"/&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp; </span>
<span>&nbsp;&nbsp;&nbsp; </span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;/</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">DataTemplate</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p>
        Windows Phone version:</p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
</span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">DataTemplate</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> x</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;">Key</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="MapItemDataTemplate"&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Phone_Controls</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Pushpin</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Cursor</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="Hand"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Content</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="{</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Binding</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Place</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">}"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Location</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="{</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Binding</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Converter</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">={</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">StaticResource</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> locationConverter</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">}}" /&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
</span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;/</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">DataTemplate</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p>
        4th, on the phone, there's no Map.MouseClick event. We have to fallback 
		to MouseLeftButtonDown/Up, as we did in the HTML client. While the 
		events are named after the mouse, actually on a real device, they 
		correspond to finger events.</p>
<p>
        5th, as for how to access Bing Maps SOAP service, it is exactly the same 
		as desktop Silverlight. This also shows the advantage of creating 
		services using standards. Client developers do not need to learn a 
		separate API for all devices.</p>
<h3>
        Consume WCF Data Services</h3>
<p>
        To consume our own WCF Data Services on Windows Phone, the code is once 
		again similar to desktop version. However, Windows Phone does not allow 
		you to generate a client proxy to a data service using Add Service 
		Reference. You're required to download the Windows Phone OData client 
		library from <a href="https://odata.codeplex.com/releases/view/54698">
		https://odata.codeplex.com/releases/view/54698</a>. Please make sure you 
		download
		<a id="fileDownload1" href="https://odata.codeplex.com/releases/view/54698#DownloadId=161862" tabindex="9">
		ODataClient_BinariesAndCodeGenToolForWinPhone.zip</a>, as it contains 
		the DataSvcUtil tool targeting Windows Phone. You can download the 
		source code of the library as well.</p>
<p>
        After the client library is downloaded, you need to manually use the 
		command line tool
		<a href="https://msdn.microsoft.com/en-us/library/ee383989.aspx">
		DataSvcUtil.exe</a> to generate the client proxy. The syntax is exactly 
		the same as desktop version. For our sample, we use:</p>
<p>
        DataSvcUtil /out:TravelDataServiceReference.cs /uri:<a href="https://127.0.0.1:81/DataService/TravelDataService.svc">https://127.0.0.1:81/DataService/TravelDataService.svc</a></p>
<p>
        Then copy the generated proxy file to the Windows Phone project. Also 
		make sure to reference System.Data.Services.Client.dll in the previously 
		downloaded Windows Phone OData client library.</p>
<p>
        Now we can write code to consume the service. Most code is exactly the 
		same as desktop Silverlight. The only difference is LINQ is not 
		supported yet in the Windows Phone library.</p>
<p>
        So instead of:</p>
<p>
<span style="font-size: 9.5pt; font-family: NSimSun;">
		<span style="color: blue;">this</span>._dataServiceContext.Travels.BeginExecute(result 
=&gt;</span></p>
<p>
        We write:</p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun;">
<span style="color: blue;">this</span>._dataServiceContext.BeginExecute&lt;<span style="color: #2b91af;">Travel</span>&gt;(<span style="color: blue;">new</span>
<span style="color: #2b91af;">Uri</span>(<span style="color: blue;">this</span>._dataServiceContext.BaseUri,
<span style="color: #a31515;">"Travels"</span>), result =&gt;</span></p>
<p>
        That is, we provide the full URI of the Travels entity set. Remember a 
		WCF Data Service is a REST service, and you request for an entity set 
		using https://ServiceBaseUri/EntitySetName.&nbsp;</p>
<h3>
        No federated authentication on Windows Phone</h3>
<p>
        One piece that we're unable to provide in our Windows Phone 
		implementation at this time is federated authentication. Since our 
		application is not running in a browser, we can't use passive federation 
		(as we do in the HTML and desktop Silverlight client). On a standard 
		alone application, you can use active federation. Unfortunately WIF is 
		not supported on the phone yet, and it could be quite difficult to deal 
		with WS-Federation manually.</p>
<p>
        While we won't provide sample code to implement federated 
		authentication, we'll discuss several options in this blog post. First, 
		ACS also supports OAuth. The OAuth protocol is much simpler than 
		WS-Federation. Using OAuth, you can issue an HTTP request to ACS to 
		obtain a token, and then put the token in the Authorization header in 
		future requests to our own cloud service. This approach however, doesn't 
		support integration with identity providers like Google, Yahoo, and 
		Facebook, at least not without additional efforts.</p>
<p>
        To work with identity providers, on solution is demonstrated in
		<a href="https://player.microsoftpdc.com/Session/0099d03d-bbc4-4612-87e1-f7d4da8b8a78">
		Vittorio's PDC session</a>. He also shipped a sample on
		<a href="https://acs.codeplex.com/releases/view/55185">
		https://acs.codeplex.com/releases/view/55185</a>. The idea is to put a
		<a href="https://msdn.microsoft.com/en-us/library/cc491073(v=VS.95).aspx">
		WebBrowser control</a> in the Silverlight application. Let the browser 
		redirect to the identity providers, and perform authentication as usual. 
		After the authentication is succeeded, the browser will be redirected to 
		ACS. The ACS HTML page contains a script
		<a href="https://msdn.microsoft.com/en-us/library/system.windows.controls.webbrowser.scriptnotify(VS.95).aspx">
		window.external.notify</a>, which is used to notify the hosting process 
		(such as our Windows Phone application) about some data. In this case, 
		the data is a security token wrapped in the JSON format. Then you parse 
		the token and use it in future requests to your own cloud services as in 
		the normal OAuth scenario.</p>
<h3>Conclusion</h3>
<p>This post described how to add a Windows Phone 
client to our existing solution. Once again, the cloud service does not need to 
be changed at all. Actually you can deploy the service to Windows Azure, and 
when developing the Windows Phone client, you can directly access the service 
from the cloud.</p>
<p>Hopefully this series has helped you to see how to create a typical cloud 
solution which contains a cloud service and multiple clients. And last but not 
least, merry Christmas. :)</p>]]></content:encoded>
    </item>
    <item>
      <title>Azure + Bing Maps: Creating a Silverlight Client</title>
      <link>https://docs.microsoft.com/archive/blogs/windows-azure-support/azure-bing-maps-creating-a-silverlight-client</link>
      <pubDate>Thu, 16 Dec 2010 23:58:33 GMT</pubDate>
      <dc:creator><![CDATA[China Windows Azure Blog]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/windows-azure-support/2010/12/16/azure-bing-maps-creating-a-silverlight-client/</guid>
      <description><![CDATA[&nbsp;
This is the 11th article in our "Bring the clouds together: Azure + Bing Maps"...]]></description>
      <content:encoded><![CDATA[<p>&nbsp;</p>
<p>This is the 11th article in our "Bring the clouds together: Azure + Bing Maps" 
        series. You can find a preview of live demonstration on
        <a href="https://sqlazurebingmap.cloudapp.net/">
        </a><a href="https://sqlazurebingmap.cloudapp.net/">https://sqlazurebingmap.cloudapp.net/</a>. For a list of articles in the series, 
        please refer to
<a href="https://blogs.msdn.com/b/windows-azure-support/archive/2010/08/11/bring-the-clouds-together-azure-bing-maps.aspx">        
https://blogs.msdn.com/b/windows-azure-support/archive/2010/08/11/bring-the-clouds-together-azure-bing-maps.aspx</a>.</p>
<h3>
        Introduction</h3>
<p>
        In our previous posts, we have created a complete web application, with 
		a cloud service hosted in our own cloud server, and a HTML client 
		consuming our own service as well as an external cloud service (Bing 
		Maps). We can say our own solution is complete. However, third party 
		developers should also be able to create their own clients to consume 
		our service. Otherwise we can only say we've created a web application, 
		not a cloud service. In this post, let's add a Silverlight client that 
		consumes both our own cloud service and the Bing Maps service. Let's 
		examine if we need to modify the service code, and thus if our service 
		is ready to be consumed by all kinds of clients.</p>
<h3>
        Using Bing Maps Silverlight Control</h3>
<h5>
        Display a map</h5>
<p>
        <a href="https://www.microsoft.com/downloads/en/details.aspx?displaylang=en&amp;FamilyID=beb29d27-6f0c-494f-b028-1e0e3187e830">
		Bing Maps Silverlight SDK</a> offers a full-featured Silverlight 
		control. It is defined in the Microsoft.Maps.MapControl namespace in the 
		Microsoft.Maps.MapControl.dll assembly. There's also a utility class 
		library defined in the Microsoft.Maps.MapControl namespace in the 
		Microsoft.Maps.MapControl.Common.dll assembly. So to use the types in 
		Silverlight XAML, you treat them as normal Silverlight types.</p>
<p>
        First import the namespaces:</p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun;">
<span>&nbsp;&nbsp; </span><span style="color: red;">
<span>&nbsp;</span>xmlns</span><span style="color: blue;">:</span><span style="color: red;">Microsoft_Maps_MapControl</span><span style="color: blue;">="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"</span></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun;">
<span>&nbsp;&nbsp; </span><span style="color: red;">
<span>&nbsp;</span>xmlns</span><span style="color: blue;">:</span><span style="color: red;">Microsoft_Maps_MapControl_Common</span><span style="color: blue;">="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl.Common"</span></span></p>
<p>
        Then define the control:</p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
</span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Maps_MapControl</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Map</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> x</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;">Name</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="map"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Margin</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="8,21,36,23"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Loaded</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="Map_Loaded"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> ZoomLevel</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="4"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> MouseClick</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="map_MouseClick"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> d</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;">LayoutOverrides</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="GridBox"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Grid.Column</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="1"&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Maps_MapControl</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Map.Center</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Maps_MapControl_Common</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Location</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> AltitudeReference</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="Ground"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Altitude</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="0"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Longitude</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="121"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Latitude</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="31"/&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;/</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Maps_MapControl</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Map.Center</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Maps_MapControl</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">MapItemsControl</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> x</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;">Name</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="mapItems"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> ItemTemplate</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="{</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">StaticResource</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> MapItemDataTemplate</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">}"/&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
</span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;/</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Maps_MapControl</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Map</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p>
        And in code behind, we provide the map's credential you obtained when 
		registering on the Bing Maps portal. If you haven't registered yet, 
		please refer to the
		<a href="../../b/windows-azure-support/archive/2010/10/22/azure-bing-maps-working-with-bing-maps.aspx">
		previous post</a>.</p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">this</span><span style="font-size: 9.5pt; font-family: NSimSun;">.map.CredentialsProvider 
= <span style="color: blue;">new</span> <span style="color: #2b91af;">
ApplicationIdCredentialsProvider</span>(<span style="color: blue;">this</span>._mapCredential);</span></p>
<p>
        In the above code, there're two interesting points. First, the Map 
		control exposes a Center property, whose type is Location. This property 
		defines the center of the map. Second, the Map class ultimately derives 
		from UserControl, so you can add custom contents to the map. In most 
		cases, you want to add shapes (such as pushpin) to the map, so let's use 
		a MapItemsControl as the Content property of the Map class. The 
		MapItemsControl class derives from ItemsControl (similar to ListBox), so 
		any knowledge you have about ItemsControl works for MapItemsControl as 
		well. For example, you can bind its data to a list, and define an 
		ItemTemplate to display the data.</p>
<h5>
        Add pushpins</h5>
<p>
        In our sample, we define the ItemsSource of the MapItemsControl to be an 
		ObservableCollection whose data is obtained from our own WCF Data 
		Services:</p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">private</span><span style="font-size: 9.5pt; font-family: NSimSun;">
<span style="color: #2b91af;">ObservableCollection</span>&lt;<span style="color: #2b91af;">Travel</span>&gt; 
_travelItems = <span style="color: blue;">new</span> <span style="color: #2b91af;">
ObservableCollection</span>&lt;<span style="color: #2b91af;">Travel</span>&gt;();</span></p>
<p>
        &nbsp;We put a Pushpin control in the MapItemsControl's ItemTemplate. So 
		a pushpin will be rendered for each item in the data source. This is 
		somewhat similar to jQuery Templates we used in our HTML client.</p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp; </span>
<span>&nbsp;&nbsp;&nbsp; </span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">DataTemplate</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> x</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;">Key</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="MapItemDataTemplate"&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp; </span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Microsoft_Maps_MapControl</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Pushpin</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Cursor</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="Hand"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Content</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="{</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Binding</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Place</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">}"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> 
Microsoft_Maps_MapControl</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">:</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;">MapLayer.Position</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="{</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">Binding</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Converter</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">={</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">StaticResource</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> locationConverter</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">}}"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Template</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="{</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">StaticResource</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> PushpinControlTemplate</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">}"</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> Style</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">="{</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">StaticResource</span><span style="font-size: 9.5pt; font-family: NSimSun; color: red;"> PushpinStyle</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">}"/&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">
<span>&nbsp;&nbsp;&nbsp; </span>
<span>&nbsp;&nbsp;&nbsp; </span></span>
<span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&lt;/</span><span style="font-size: 9.5pt; font-family: NSimSun; color: #a31515;">DataTemplate</span><span style="font-size: 9.5pt; font-family: NSimSun; color: blue;">&gt;</span><span style="font-size: 9.5pt; font-family: NSimSun;"></span></p>
<p>
        Just like a normal Silverlight control, you can modify the 
		ControlTemplate of the Bing Maps controls, if you want to perform custom 
		rendering. For example, you can add videos for each pushpin. Anyway, 
		when working with Bing Maps Silverlight control, you can take advantage 
		of all mighty of Silverlight.</p>
<h5>
        Working with Bing Maps cloud service</h5>
<p>
        We have demonstrated how to consume Bing Maps REST services in our HTML 
		client. So this time, let's demonstrate SOAP services. To consume the 
		SOAP service, you add a service reference to the proper URI such as
		<a href="https://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc/mex">
		https://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc/mex</a>, 
		just like referencing a normal WCF SOAP service.</p>
<p>
        Actually Bing Maps SOAP services are indeed WCF SOAP Services, and it's 
		fully compatible with Silverlight. The cross domain access policy file 
		has been configured, and it supports both BasicHttpBinding and a custom 
		binding that uses Silverlight binary serialization.</p>
<p>
        In our sample, we handle the map's MouseClick event, and invoke the SOAP 
		service to obtain detailed information of the clicked place. Unlike AJAX 
		control, the Silverlight map's click event won't be invoked if the mouse 
		moved when panning the map. So it's safe to use.</p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
<span style="color: blue;">private</span> <span style="color: blue;">void</span> 
map_MouseClick(<span style="color: blue;">object</span> sender, 
Microsoft.Maps.MapControl.<span style="color: #2b91af;">MapMouseEventArgs</span> 
e)</span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
{</span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="color: #2b91af;">ReverseGeocodeRequest</span> request =
<span style="color: blue;">new</span> <span style="color: #2b91af;">
ReverseGeocodeRequest</span>() { Location = 
map.ViewportPointToLocation(e.ViewportPoint) };</span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span>request.Credentials = <span style="color: blue;">new</span>
<span style="color: #2b91af;">Credentials</span>() { Token =
<span style="color: blue;">this</span>._mapCredential };</span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span>_geocodeClient.ReverseGeocodeAsync(request);</span></p>
<p class="MsoNormal">
<span style="font-size: 9.5pt; font-family: NSimSun;">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
}</span></p>
<p>
        After the response is returned, we can create a new Travel object 
		according to the response, and add it to t