Reputation: 2107
I have a map with Pushpin
:
<maps:Map ZoomLevel="18" Height="575" x:Name="map1" Width="415" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,0,-10,0">
<toolkit1:MapExtensions.Children>
<toolkit1:Pushpin x:Name="push1" GeoCoordinate="" Content="" Background="Gray" ContentTemplate="{StaticResource Template_Content}">
</toolkit1:Pushpin>
</toolkit1:MapExtensions.Children>
</maps:Map>
I try to set properties from the code:
map1.Center = currentObject.Coords;
push1.GeoCoordinate = currentObject.Coords;
push1.Content = currentObject.Name;
So Map
works, but Pushpin
returns NullReference Exception
. What the reason and how to fix?
Upvotes: 1
Views: 57
Reputation: 2778
map1.Center = currentObject.Coords;
Pushpin pushpin = (Pushpin)this.FindName("push1");
pushpin .GeoCoordinate = currentObject.Coords;
pushpin .Content = currentObject.Name;
Upvotes: 2