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}"
SelectedItem="{Binding SelectedPushpin}"
SelectionMode="Multiple"
SelectionChanged="MapItemsControlSelectionChanged"
DoubleTapped="MapItemsControlDoubleTapped">
SelectionChanged="MapItemsControlSelectionChanged">
<map:MapItemsControl.Styles>
<Style Selector="map|MapItem">
<Setter Property="map:MapPanel.Location" Value="{Binding Location}"/>

View file

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

View file

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

View file

@ -36,15 +36,13 @@ namespace SampleApplication
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)
{
if (e.OriginalSource is Map map)
{
map.TargetCenter = map.ViewToLocation(e.GetPosition(map));
}
}
private void ResetHeadingButtonClick(object sender, RoutedEventArgs e)
{