The main page of our application is built using the Pivot control, on one of the bookmarks of which it was necessary to place a map with information about the location of the car. Users of our application, it was decided to provide a choice between map services from Microsoft and Yandex.using System.Windows; using Yandex.Maps; namespace YandexMapKit { public static class YandexMapHelper { public static readonly DependencyProperty FixManipulationProperty = DependencyProperty.RegisterAttached( "FixManipulation", typeof(bool), typeof(YandexMapHelper), new PropertyMetadata(OnFixManipulationChanged)); public static void SetFixManipulation(DependencyObject element, bool value) { element.SetValue(FixManipulationProperty, value); } public static bool GetFixManipulation(DependencyObject element) { return (bool) element.GetValue(FixManipulationProperty); } private static void OnFixManipulationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var map = d as Map; if (map == null) { return; } var fixManipulation = (bool?) e.NewValue; if (fixManipulation == true) { map.UseOptimizedManipulationRouting = false; map.ManipulationStarted += MapManipulationStarted; map.ManipulationCompleted += MapManipulationCompleted; map.ManipulationDelta += MapManipulationDelta; return; } fixManipulation = (bool?)e.OldValue; if (fixManipulation == true) { map.UseOptimizedManipulationRouting = true; map.ManipulationStarted -= MapManipulationStarted; map.ManipulationCompleted -= MapManipulationCompleted; map.ManipulationDelta -= MapManipulationDelta; } } private static void MapManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { e.Handled = true; } private static void MapManipulationCompleted(object sender, System.Windows.Input.ManipulationCompletedEventArgs e) { e.Handled = true; } private static void MapManipulationStarted(object sender, System.Windows.Input.ManipulationStartedEventArgs e) { e.Handled = true; } } } <phone:Pivot Title="YANDEX MAPKIT TEST APP"> <phone:PivotItem Header=""> <StackPanel> <RichTextBox VerticalAlignment="Top" VerticalContentAlignment="Top"> <Paragraph> <Run Text=" Map Yandex.Maps MapKit Pivot"/> </Paragraph> </RichTextBox> <CheckBox x:Name="viewFixManipulation" Content=" " VerticalAlignment="Top" /> </StackPanel> </phone:PivotItem> <phone:PivotItem Header=""> <Grid> <yandexMaps:Map yandexMapKit:YandexMapHelper.FixManipulation="{Binding IsChecked, ElementName=viewFixManipulation}" /> </Grid> </phone:PivotItem> </phone:Pivot> Source: https://habr.com/ru/post/221477/
All Articles