This project has moved. For the latest updates, please go here.

About dragging the pin to change the position of the pin on the map

Mar 20 at 1:45 AM
Edited Mar 20 at 1:46 AM
    <Style x:Key="PointItemStyle" TargetType="Maps:MapItem">
        <Setter Property="helper:BindingHelper.LocationPath" Value="Location"/>
        <Setter Property="Foreground" Value="Black"/>
        <Setter Property="Template">
                <ControlTemplate TargetType="Maps:MapItem">
                    <Canvas PointerMoved="Pushpin_PointerMoved">
                            <Path Fill="GreenYellow" Stroke="Green" StrokeThickness="2">
                                    <EllipseGeometry RadiusX="8" RadiusY="8"/>
                            <Rectangle x:Name="labelBackground" Fill="White" Opacity="0.7"/>
                            <TextBlock Margin="2,0,2,0" Text="{Binding DisplayName}"/>

    private void Pushpin_PointerMoved(object sender, PointerRoutedEventArgs e)
        var pointerPosition = e.GetCurrentPoint(PlanningMapControl);
        var point = e.GetCurrentPoint((UIElement)sender);
        if (point.Properties.IsLeftButtonPressed)
            Location location = PlanningMapControl.ViewportPointToLocation(pointerPosition.Position);
                PushpinViewModels.Pushpins[index].Location = location;}}
Why is this wrong? Is there any good way? thank you very much!
Mar 20 at 5:07 PM
Edited Mar 20 at 5:08 PM
The PointerMoved event should not be handled on an element inside the item container's visual tree, because the item container is itself moving around (to the item's Location). Handle the event on an element outside of the MapItemsControl.
Mar 21 at 2:10 AM
Very grateful to ClemensF, I am a beginner, the following is the call to the map of XAML:
    <Maps:Map x:Name="PlanningMapControl" TileLayer="{Binding [OpenStreetMap], Source={StaticResource TileLayers}}" 
              MinZoomLevel="2" ZoomLevel="5" ManipulationMode="All" Loaded="PlanningMapControl_Loaded" Tapped="PlanningMapControl_MapTapped" >

            <Maps:MapItemsControl ItemsSource="{x:Bind PushpinViewModels.Pushpins}" ItemContainerStyle="{StaticResource PointItemStyle}"/>


How should I modify it? Can I provide some code? thank you very much!
Mar 22 at 6:35 PM
Sorry, this is not the right place for a beginner's education. Please do your own research. When you have a specific problem related to the map control, we'll be pleased to help.