[英]Can't set the pushpin properties (WP8)
I have a map with Pushpin
: 我有一个
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
. 因此
Map
可以工作,但是Pushpin
返回NullReference Exception
。 What the reason and how to fix? 是什么原因以及如何解决?
map1.Center = currentObject.Coords;
Pushpin pushpin = (Pushpin)this.FindName("push1");
pushpin .GeoCoordinate = currentObject.Coords;
pushpin .Content = currentObject.Name;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.