Skip to content
March 28, 2011 / slimcode

Late-binding, Bing Maps and Pushpins with an unknown position

It seems the Bing Maps controls for Windows Phone 7 have a little problem when you use late-binding (setting the data context in the Loaded event, for example) and you have a Pushpin with a Location set to GeoCoordinate.Unknown. For example, take this Pushpin declaration:

  1. <map:Pushpin Location="{Binding UserPosition}" Content="you" Visibility="{Binding UserPosition, Converter={StaticResource GeoCoordinateVisibilityConverter}}" />


Even if you change the pushpin’s visibility to Collapsed for unknown locations, you end up with an ugly exception:

System.InvalidOperationException occurred:
  Message=UIElement.Arrange(finalRect) cannot be called with Infinite or NaN values in finalRect.

Well, that’s great info, right? The workaround I found was to insert that pushpin in a layer, and collapse the layer for the same criteria:

  1. <map:MapLayer Visibility="{Binding UserPosition, Converter={StaticResource GeoCoordinateVisibilityConverter}}">
  2.     <map:Pushpin Location="{Binding UserPosition}" Content="you" />
  3. </map:MapLayer>


A little overhead, but it works.



Leave a Comment
  1. Masaki Katata / Mar 29 2011 04:02

    I’m Understanding Homepage Thank you

  2. / Mar 29 2011 11:21

    Why dont you try to bind to an object that implements INotifyPropertyChanged


  3. slimcode / Mar 29 2011 12:09

    I do implement INotifyPropertyChanged.

    I’m using the “late-binding” term, but it’s really about setting the DataContext in the page’s Loaded event instead of at construction or declared in the XAML.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: