Does anyone know how to databind pushpins in the Nokia Map control? Thanks!

有帮助吗?

解决方案

You can use the Windows Phone Toolkit to add children to the map. The Toolkit contains some controls and extensions that make this easier to work with.

<maps:Map x:Name="myMap">
    <toolkit:MapExtensions.Children>
        <toolkit:UserLocationMarker x:Name="UserLocationMarker" />
        <toolkit:Pushpin x:Name="MyPushpin" Content="My Position"></toolkit:Pushpin>
    </toolkit:MapExtensions.Children>
</maps:Map>

You can even use templating to bind to a collection of items.

<maps:Map x:Name="myMap">
    <toolkit:MapExtensions.Children>
        <toolkit:MapItemsControl ItemsSource="{Binding MapItems}">
            <toolkit:MapItemsControl.ItemTemplate>
                <DataTemplate>
                    <toolkit:Pushpin GeoCoordinate="{Binding Coordinate}" Content="{Binding Name}" />
                </DataTemplate>
            </toolkit:MapItemsControl.ItemTemplate>
        </toolkit:MapItemsControl>
    </toolkit:MapExtensions.Children>
</maps:Map>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top