簡體   English   中英

無法設置圖釘屬性(WP8)

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM