Sample Applications DoubleTapped

This commit is contained in:
ClemensFischer 2024-08-25 18:02:23 +02:00
parent 45b6c012e0
commit 49bd02863a
4 changed files with 13 additions and 25 deletions

View file

@ -64,8 +64,7 @@
<map:MapItemsControl ItemsSource="{Binding Pushpins}" <map:MapItemsControl ItemsSource="{Binding Pushpins}"
SelectedItem="{Binding SelectedPushpin}" SelectedItem="{Binding SelectedPushpin}"
SelectionMode="Multiple" SelectionMode="Multiple"
SelectionChanged="MapItemsControlSelectionChanged" SelectionChanged="MapItemsControlSelectionChanged">
DoubleTapped="MapItemsControlDoubleTapped">
<map:MapItemsControl.Styles> <map:MapItemsControl.Styles>
<Style Selector="map|MapItem"> <Style Selector="map|MapItem">
<Setter Property="map:MapPanel.Location" Value="{Binding Location}"/> <Setter Property="map:MapPanel.Location" Value="{Binding Location}"/>

View file

@ -36,14 +36,12 @@ namespace SampleApplication
map.TargetHeading = 0d; map.TargetHeading = 0d;
} }
private void MapItemsControlDoubleTapped(object sender, TappedEventArgs e)
{
e.Handled = true; // prevent MapDoubleTapped
}
private void MapDoubleTapped(object sender, TappedEventArgs e) private void MapDoubleTapped(object sender, TappedEventArgs e)
{ {
map.TargetCenter = map.ViewToLocation(e.GetPosition(map)); if (e.Source == map)
{
map.TargetCenter = map.ViewToLocation(e.GetPosition(map));
}
} }
private void MapPointerPressed(object sender, PointerPressedEventArgs e) private void MapPointerPressed(object sender, PointerPressedEventArgs e)
@ -52,11 +50,7 @@ namespace SampleApplication
{ {
var point = e.GetCurrentPoint(map); var point = e.GetCurrentPoint(map);
if (point.Properties.IsLeftButtonPressed) if (point.Properties.IsRightButtonPressed)
{
map.Cursor = new Cursor(StandardCursorType.Hand);
}
else if (point.Properties.IsRightButtonPressed)
{ {
e.Pointer.Capture(map); e.Pointer.Capture(map);
var location = map.ViewToLocation(point.Position); var location = map.ViewToLocation(point.Position);
@ -76,11 +70,10 @@ namespace SampleApplication
if (e.Pointer.Captured == map) if (e.Pointer.Captured == map)
{ {
e.Pointer.Capture(null); e.Pointer.Capture(null);
map.Cursor = null;
measurementLine.IsVisible = false; measurementLine.IsVisible = false;
measurementLine.Locations = null; measurementLine.Locations = null;
} }
map.Cursor = null;
} }
private void MapPointerMoved(object sender, PointerEventArgs e) private void MapPointerMoved(object sender, PointerEventArgs e)

View file

@ -163,16 +163,14 @@
<map:MapItemsControl ItemContainerStyle="{StaticResource PointItemStyle}" <map:MapItemsControl ItemContainerStyle="{StaticResource PointItemStyle}"
ItemsSource="{Binding Points}" ItemsSource="{Binding Points}"
SelectionMode="Multiple" SelectionMode="Multiple"
LocationMemberPath="Location" LocationMemberPath="Location"/>
DoubleTapped="MapItemsControlDoubleTapped"/>
<map:MapItemsControl ItemContainerStyle="{StaticResource PushpinItemStyle}" <map:MapItemsControl ItemContainerStyle="{StaticResource PushpinItemStyle}"
ItemsSource="{Binding Pushpins}" ItemsSource="{Binding Pushpins}"
SelectedItem="{Binding SelectedPushpin, Mode=TwoWay}" SelectedItem="{Binding SelectedPushpin, Mode=TwoWay}"
SelectionMode="Multiple" SelectionMode="Multiple"
LocationMemberPath="Location" LocationMemberPath="Location"
SelectionChanged="MapItemsControlSelectionChanged" SelectionChanged="MapItemsControlSelectionChanged"/>
DoubleTapped="MapItemsControlDoubleTapped"/>
<map:MapPath Location="53.5,8.2" Stroke="Blue" StrokeThickness="3" Fill="#1F007F00" IsHitTestVisible="False"> <map:MapPath Location="53.5,8.2" Stroke="Blue" StrokeThickness="3" Fill="#1F007F00" IsHitTestVisible="False">
<map:MapPath.Data> <map:MapPath.Data>

View file

@ -36,14 +36,12 @@ namespace SampleApplication
Debug.WriteLine("SelectedItems: " + string.Join(", ", ((MapItemsControl)sender).SelectedItems.OfType<PointItem>().Select(item => item.Name))); Debug.WriteLine("SelectedItems: " + string.Join(", ", ((MapItemsControl)sender).SelectedItems.OfType<PointItem>().Select(item => item.Name)));
} }
private void MapItemsControlDoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
{
e.Handled = true; // prevent MapDoubleTapped
}
private void MapDoubleTapped(object sender, DoubleTappedRoutedEventArgs e) private void MapDoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
{ {
map.TargetCenter = map.ViewToLocation(e.GetPosition(map)); if (e.OriginalSource is Map map)
{
map.TargetCenter = map.ViewToLocation(e.GetPosition(map));
}
} }
private void ResetHeadingButtonClick(object sender, RoutedEventArgs e) private void ResetHeadingButtonClick(object sender, RoutedEventArgs e)