<Grid x:Name="LayoutRoot" Background="White"> <esri:Map x:Name="MyMap"> <esri:Map.Extent> <esri:Envelope XMin="-178.217598362366" YMin="18.921786345087" XMax="-66.9692709841984" YMax="71.4062353672549"> <esri:Envelope.SpatialReference> <esri:SpatialReference WKID="4269"/> </esri:Envelope.SpatialReference> </esri:Envelope> </esri:Map.Extent> <esri:FeatureLayer ID="MyStateLayer" Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5" OutFields="*"/> <esri:FeatureLayer ID="MyCountyLayer" Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3" OutFields="*" /> </esri:Map> <StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center"> <ComboBox x:Name="MyStates" ItemsSource="{Binding ElementName=MyMap, Path=Layers[MyStateLayer].Graphics}" SelectionChanged="ComboBox_SelectionChanged"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Attributes[STATE_NAME]}"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> <ComboBox x:Name="MyCounties" ItemsSource="{Binding ElementName=MyMap, Path=Layers[MyCountyLayer].Graphics}"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Attributes[CNTY_FIPS]}"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> <TextBlock Text="{Binding ElementName=MyStates, Path=SelectedItem.Attributes[STATE_NAME], StringFormat='STATE_NAME = "\{0\}"'}"/> </StackPanel> </Grid>
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { var stateName = ((sender as ComboBox).SelectedItem as Graphic).Attributes["STATE_NAME"] as string; FeatureLayer countyLayer = this.MyMap.Layers["MyCountyLayer"] as FeatureLayer; countyLayer.Where = string.Format("STATE_NAME = '{0}'", stateName); countyLayer.Update(); }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.