public partial class TestScrollViewer : UserControl { public TestScrollViewer() { InitializeComponent(); MyMap.Loaded += AttachMouseLeftButtonHandlers; // maybe set in XAML as well : Loaded="AttachMouseLeftButtonHandlers" } private void AttachMouseLeftButtonHandlers(object sender, RoutedEventArgs e) { Map map = sender as Map; // Get the "RootElement" of the map ~ of map.GetTemplateChild("RootElement") but GetTemplateChild is protected and Map is sealed var rootElement = ((FrameworkElement)VisualTreeHelper.GetChild(map, 0)).FindName("RootElement") as Grid; if (rootElement != null) { rootElement.MouseLeftButtonDown += RootElement_MouseLeftButtonDown; rootElement.MouseLeftButtonUp += (s, arg) => _upFired = true; } } // Hack to get the map taking care of the MouseLeftButtonDown event even if // this event is handled by the a parent element such as a scrollviewer private bool _upFired; void RootElement_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { _upFired = false; Dispatcher.BeginInvoke(() => { if (!_upFired) // else up event fired meanwhile e.Handled = false; }); } }
What do you mean? I just tested and I am able to view the live application and I am able to download the code and get the ScrollableMap.cs file.
<ScrollViewer Margin="0,8,8,8" BorderBrush="{x:Null}" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"> <Grid x:Name="GridThatHoldsTheContent"/> </ScrollViewer>
<!-- ... --> <StackPanel Grid.Row="0" MaxHeight="1454" VerticalAlignment="Top" Margin="25,25,28,0"> <Border BorderThickness="1" BorderBrush="Black"> <Grid> <esri:Map x:Name="Mapa" VerticalAlignment="Top" WrapAround="True" Background="#FFC3D2E5" IsLogoVisible="False" Height="1187"> <i:Interaction.Triggers> <i:EventTrigger EventName="ExtentChanged"> <i:InvokeCommandAction Command="{Binding AcaoExtentChanged}" CommandParameter="{Binding ElementName=Mapa}"/> <ei:CallMethodAction MethodName="InvocaOMetodoDeHistoricosDoMapaNaViewModel" TargetObject="{Binding ElementName=PaginaRetratoA3}"/> <ei:CallMethodAction MethodName="ConfiguraExibicaoDeLegenda" TargetObject="{Binding ElementName=PaginaRetratoA3}"/> </i:EventTrigger> </i:Interaction.Triggers> </esri:Map> <esri:Navigation VerticalAlignment="Bottom" Margin="10,0,0,10" Background="#FF336397" Style="{StaticResource EstiloNavegadorImpressao}" Map="{Binding ElementName=Mapa}"/> </Grid> </Border> <!-- ... --> </StackPanel>
The sample didn't open...
Look at this sample. There is a hack at the end of ScrollableMap.cs (without any guarantee though)
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.