<StackPanel VerticalAlignment="Top" HorizontalAlignment="Center"> <RadioButton x:Name="Rb" Content="Test" Tag="{Binding ElementName=MyMap}" Click="RadioButton_Click"/> <RadioButton x:Name="Rb2" Content="Test" Tag="{Binding ElementName=MyMap2}" Click="RadioButton_Click"/> </StackPanel>
private void RadioButton_Click(object sender, RoutedEventArgs e) { var rb = sender as RadioButton; if (rb.IsChecked.HasValue && rb.IsChecked.Value) MyLegend.Map = rb.Tag as Map; }
i tried your solution but it didnt work.i want when i click in the radiobutton of map1....the map1 appear..and if i want the map2..i click in the other radiobutton.
i mean when i click on the radiobutton of "map1", the map1 appear ine the screen with his legend, and when i click on radiobutton of map2, the map2 appear with his legend.i wish i explained well what i want !!
<Grid x:Name="LayoutRoot" Background="White"> <esri:Map x:Name="Map1" Extent="-20037507.0671618,-20037507.0671618,20037507.0671618,20037507.0671619"> <esri:ArcGISTiledMapServiceLayer ID="basemap" DisplayName="Base Map 1" Url="http://services.arcgisonline.com/arcgis/rest/services/world_topo_map/MapServer" /> <esri:FeatureLayer ID="points" DisplayName="Incident Points" Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer/0" DisableClientCaching="True"/> </esri:Map> <esri:Map x:Name="Map2" Extent="-20037507.0671618,-20037507.0671618,20037507.0671618,20037507.0671619" Visibility="Collapsed"> <esri:ArcGISTiledMapServiceLayer ID="basemap" DisplayName="Base Map 2" Url="http://services.arcgisonline.com/arcgis/rest/services/world_topo_map/MapServer" /> <esri:FeatureLayer ID="lines" DisplayName="Incident Lines" Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer/1" DisableClientCaching="True"/> <esri:FeatureLayer ID="polygons" DisplayName="Incident Polygons" Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer/2" DisableClientCaching="True"/> </esri:Map> <Grid VerticalAlignment="Bottom" HorizontalAlignment="Right"> <esri:Legend x:Name="Legend1" Map="{Binding ElementName=Map1}" LayerIDs="points" /> <esri:Legend x:Name="Legend2" Map="{Binding ElementName=Map2}" LayerIDs="lines,polygons" Visibility="Collapsed" /> </Grid> <StackPanel VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10"> <RadioButton GroupName="MapSwitcher" Tag="1" Content="Display Map 1" IsChecked="True" Click="RadioButton_Click" /> <RadioButton GroupName="MapSwitcher" Tag="2" Content="Display Map 2" IsChecked="False" Click="RadioButton_Click" /> </StackPanel> </Grid>
private void RadioButton_Click(object sender, RoutedEventArgs e) { string tag = (sender as RadioButton).Tag as string; switch (tag) { case "1": Map1.Visibility = Visibility.Visible; Legend1.Visibility = Visibility.Visible; Map2.Visibility = Visibility.Collapsed; Legend2.Visibility = Visibility.Collapsed; break; case "2": Map2.Visibility = Visibility.Visible; Legend2.Visibility = Visibility.Visible; Map1.Visibility = Visibility.Collapsed; Legend1.Visibility = Visibility.Collapsed; break; } } }
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.