Filtering a FeatureLayer Online

This sample demonstrates applying filters to a Feature Layer. Filters allow you to retrieve a subset of records from a map service layer or spatial data service table that match an attribute or spatial query. The sample includes to feature layers, one with an attribute filter and the other with a spatial filter. As the sample shows, an attribute filter is specified by defining a query in the layer's Where property. A spatial filter is specified by defining the layer's Geometry property.
Download Sample Application<UserControl x:Class="ArcGISWPFSDK.FeatureLayerFiltering" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:esri="http://schemas.esri.com/arcgis/client/2009"> <Grid x:Name="LayoutRoot" Background="White"> <Grid.Resources> <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/> <esri:SimpleRenderer x:Key="MySimplePointRenderer"> <esri:SimpleRenderer.Symbol> <esri:SimpleMarkerSymbol Color="Orange"/> </esri:SimpleRenderer.Symbol> </esri:SimpleRenderer> <esri:SimpleRenderer x:Key="MySimplePolygonRenderer"> <esri:SimpleRenderer.Symbol> <esri:SimpleFillSymbol Fill="#440000FF"/> </esri:SimpleRenderer.Symbol> </esri:SimpleRenderer> </Grid.Resources> <esri:Map x:Name="MyMap" WrapAround="True" Background="#FFE3E3E3"> <esri:Map.Extent> <esri:Envelope XMin="-15000000" YMin="2000000" XMax="-7000000" YMax="8000000"> <esri:Envelope.SpatialReference> <esri:SpatialReference WKID="102100"/> </esri:Envelope.SpatialReference> </esri:Envelope> </esri:Map.Extent> <esri:Map.Layers> <esri:ArcGISTiledMapServiceLayer ID="TopoMapLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/> <esri:FeatureLayer ID="SpatialFilterFeatureLayer" Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3" Renderer="{StaticResource MySimplePolygonRenderer}"> <esri:FeatureLayer.Geometry> <esri:Envelope XMin="-100" YMin="42" XMax="-95" YMax="47" > <esri:Envelope.SpatialReference> <esri:SpatialReference WKID="4326"/> </esri:Envelope.SpatialReference> </esri:Envelope> </esri:FeatureLayer.Geometry> </esri:FeatureLayer> <esri:FeatureLayer ID="AttributeFilterFeatureLayer" Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/0" Where="POP1990 > 1000000" Renderer="{StaticResource MySimplePointRenderer}"> </esri:FeatureLayer> </esri:Map.Layers> </esri:Map> <ProgressBar x:Name="MyProgressBar" IsIndeterminate="True" VerticalAlignment="Bottom" Width="200" Height="20" Margin="10" Visibility="{Binding Path=IsBusy, Converter={StaticResource BooleanToVisibilityConverter}}"></ProgressBar> </Grid> </UserControl>
5/16/2014