I am trying to add a map to a Windows 8 Store app using the Bing Map SDK and control. With this set of Xaml:
<Page.Resources>
<DataTemplate x:Key="LogoTemplate">
<m:Pushpin m:MapLayer.Position="{Binding Item2}" Text="{Binding Item1}"/>
</DataTemplate>
</Page.Resources>
...
<m:Map Credentials="{StaticResource BingMapsApiKey}" ZoomLevel="12" HomeRegion="US" Heading="2">
<m:MapItemsControl x:Name="ListOfItems"
ItemTemplate="{StaticResource LogoTemplate}"
ItemsSource="{Binding LocationList}">
</m:MapItemsControl>
</m:Map>
Bound to this Property of the view model:
public IEnumerable<Tuple<string, Bing.Maps.Location>> LocationList
{
get
{
if (MapLocation != null)
{
return new List<Tuple<string, Bing.Maps.Location>>
{
new Tuple<string, Bing.Maps.Location>("1", new Bing.Maps.Location(MapLocation.lat, MapLocation.lng))
};
}
return Enumerable.Empty<Tuple<string, Bing.Maps.Location>>();
}
}
It consistently excepts with an E_FAIL HResult from a COM component in Bing maps. With this message in the debugger output window:
WinRT information: Failed to assign to property 'Bing.Maps.MapLayer.Position'
Lat and Long are valid points. I am stumped and cannot see anything to do differently. The interwebs has very little information about the App Store version of the Bing Maps control so am hoping somebody has gotten this to work.
Just in case anybody else has this issue (or also encounters difficulty integrating the windows store version of this control to a MVVM model) it looks like the solution is to wrap the control in a bindable version. I used this code form codeplex with some success so far.