[英]Can't set the pushpin properties (WP8)
我有一個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>
我嘗試從代碼中設置屬性:
map1.Center = currentObject.Coords;
push1.GeoCoordinate = currentObject.Coords;
push1.Content = currentObject.Name;
因此Map
可以工作,但是Pushpin
返回NullReference Exception
。 是什么原因以及如何解決?
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.