15

Edit: the described issue below occurs also in a Win 10 UWP application (VS2015, Win10) when using the MapControl.

I have a weird problem using the MapControl in a Windows Phone 8.1 (universal app) application. After adding the control to a page, Visual Studio says The name "MapControl" does not exist in the namespace "using:Windows.UI.Xaml.Controls.Maps". Building the app works, I can deploy it to the phone and the map is shown and everything is fine - but I cannot use the Designer for this page any longer since it claims that error.

The problem occured in a bigger project originally started in VS2013 (update 4) on Windows 8.1. My first thought was that my VS-installation was kind of broken. But also after a clean new installation of Windows 10 (10240) and VS2015 RTM the problem occured. My steps to reproduce are quite simple:

  • Create a new project from template "Blank App (Universal Windows 8.1)"
  • Open the MainPage.xaml of the WindowsPhone subproject
  • Double click the MapControl in the toolbox
  • Note that the MapControl is added to the Grid in xaml and it is shown in side-by-side design view. Everything seems to be ok.
  • I can now add more controls to the page just by clicking the toolbox. I can modify the controls on the page with the mouse in the designer (e.g. rearrange them) and I can change their properties by the properties pane. Everything is still ok.
  • But when I either close and reopen that page (or the whole project) in the designer or when I start to edit the xaml directly with the keyboard, the designer fails and claims the error described above.

What's the problem here? How can I make Visual Studio designer to work with pages with MapControls again? First I thought of a bug in VS2013 - but that simple to reproduce, not fixed in VS2015 and no information about it on the internet? What did I wrong?

Design view and xaml is broken after editing (but compilation and deploying works)

Torben Schramme
  • 2,104
  • 1
  • 16
  • 28
  • 2
    I'm having a same error even using UWP project on Windows 10, VS2015 RC. – Nghia Nguyen Aug 20 '15 at 05:06
  • Same error, but looks like it is not impacting deploying the app to the store. – gavi Aug 22 '15 at 19:14
  • 1
    No, it's not impacting the deploy. But when the map is a central ui element in your app, you have to develop the whole app without the visual designer which makes development much harder. – Torben Schramme Aug 22 '15 at 19:30

3 Answers3

1

There is a bug on Visual Studio Tools for Universal Windows Apps 1.0 causing this issue with the map, installing this update should fix the issue Update

Procedure to correctly use the map sdk

Windows 8.1

  1. Go to Tools-> extension and update -> install Bing Map SDK.
  2. Right click on the project->Add reference->Windows->Extensions->Bing maps
  3. Set configuration to x86 (Configuration Properties -> Configuration)
  4. Add the map reference to your page using xmlns:maps="using:Bing.Maps"
  5. Adding this line to your xaml <maps:Map />

and now you are good to go

Windows Phone and Windows 10 UAP

Add this reference in your xaml

xmlns:maps="using:Windows.UI.Xaml.Controls.Maps"

and then add this line to your xaml

<maps:MapControl />
Community
  • 1
  • 1
frenk91
  • 919
  • 1
  • 15
  • 30
  • Your procedure is only a workaround for x86 windows 8.1 and seems not to work on wp8.1 or wp10 universal windows platform as I asked in the question. The Bing Maps SDK Extension is only available for Windows 8.1 Store Apps. And it seems to be a different API. I want to know how to get this API to work: https://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.xaml.controls.maps.mapcontrol.aspx or https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/MapControl – Torben Schramme Sep 09 '15 at 21:20
  • In a universal app for windows 8.1 you have a project for WP8.1 and one for windows 8.1, the procedure i wrote explains how to use maps in 2 different projects, because the SDK is different you need 2 different views for showing the map, one for each project. If your project have as target Win10 UAP you need only the windows phone part of my answer, you don't need an sdk, because the sdk is already included. – frenk91 Sep 10 '15 at 07:37
  • Look at the screenshot I provided. The two lines you suggested for Win10 are exactly what I wrote. The problem is not that the MapControl is not found at all. It is found, it can be added via the toolbox, it is visible in the designer and it works at runtime. BUT: It works only until first manual editing of the XAML file. After that, the Designer seems to be broken and claims that the namespace is not found. It still works at runtime at this point but no longer in the Designer. And it seems I'm not the only one with that problem so I want to know, if there is a workaround/fix for this. – Torben Schramme Sep 10 '15 at 22:43
  • 1
    there is a bug on visual studio causing the issue with the map, install this update should fix the issue https://social.msdn.microsoft.com/Forums/en-US/e9df01f6-1474-4a4e-98fc-2567591c764f/update-11-release-notes-and-installation-instructions?forum=Win10SDKToolsIssues – frenk91 Sep 17 '15 at 10:31
  • Indeed, this update solved the problem. Can you edit your answer again and put the relevant information right at the start? Perhaps with some more information? As discussed, the first information you provided were not what I've asked for. But because you posted the link earlier than Justin XL, I will give your answer the green check if it will be improved a bit – Torben Schramme Sep 20 '15 at 15:20
  • Oops I didn't see your updated answer otherwise I wouldn't have bothered creating a new one. – Justin XL Sep 20 '15 at 17:59
-1

Set configuration to x86 instead of "Any CPU". For prioritising fix upvote at https://connect.microsoft.com/VisualStudio/feedback/details/1659249/visual-studio-2015-rtm-uwp-the-name-mapcontrol-does-not-exist-in-the-namespace-using-windows-ui-xaml-controls-maps

Chawathe Vipul S
  • 1,636
  • 15
  • 28
  • Unfortunately that does not solve my problem here. The same issue occurs now in a win 10 UWP project when using MapControl. The link you provided points to a bug that is marked as "duplicated" but with no information where the duplicated ticket can be found. No information when it will be fixed. Very frustrating... – Torben Schramme Sep 03 '15 at 20:40
-1

Make the correct map library reference

xmlns:Maps="clr-namespace:Microsoft.Phone.Maps.Controls;assembly=Microsoft.Phone.Maps"

Instead of

xmlns:Maps="using:Microsoft.Phone.Maps.Controls;assembly=Microsoft.Phone.Maps"
Rehan Parvez
  • 143
  • 2
  • 17
  • I am talking about the .net universal apps either for wp8.1/win8.1 or for win 10. I asked for the namespace Windows.UI.Xaml.Controls.Maps and not Microsoft.Phone.Maps.Controls. Please read my question carefully. If I would address wp8.1, the using syntax won't work but that would lead to a different exception. More about this can be found here: http://stackoverflow.com/questions/16406038/xaml-clr-namespace-using-incompatibility – Torben Schramme Sep 09 '15 at 21:10