windows phone 7 - Assign geo coordinates to a pushpin -
windows phone 7 - Assign geo coordinates to a pushpin -
guys need help, have map
xmlns:maps="clr-namespace:microsoft.phone.maps.controls;assembly=microsoft.phone.maps" xmlns:maptk="clr-namespace:microsoft.phone.maps.toolkitassembly=microsoft.phone.controls.toolkit" <maps:map grid.row="0" tap="onm_mapcontroltap" name="m_mapcontrol <maptk:mapextensions.children> <maptk:pushpin x:name="m_pushpin" tap="onpushpintap"> <maptk:pushpin.content> <stackpanel> <textblock text=""/> <image source=""/> </stackpanel> </maptk:pushpin.content> </maptk:pushpin> </maptk:mapextensions.children> </maps:map>
when have coordinates geowatcher, or when tap on map, wanna add together coordinates pushpin.
m_pushpin.geocoordinate = m_watcher.position.location;
an exception of type 'system.nullreferenceexception' occurred m_pushpin, cannot understand why pushpin null. can tell me i'm doing wrong, , how can prepare this?
this known issue xaml parser. since pushpin nested in attached dependency property (mapextensions.children) won't part of same logical tree usercontrol , such won't picked findname in scope.
instead, should manually traverse visual tree , command need. luckily, map command ships helper methods occasion.
var pushpin = mapextensions.getchildren(mymap).oftype<pushpin>().first(p => p.name == "m_pushpin");
windows-phone-7 map windows-phone-8 silverlight-toolkit pushpin
Comments
Post a Comment