Dynamic Layers in XAML Online

This sample demonstrates using XAML to specify the LayerDefinitions, LayerDrawingOptions, and DynamicLayerInfos of an ArcGISDynamicMapServiceLayer. The LayerDefinition sets the USCities layer to only show capitals. The LayerDrawingOptions set Layers 0 and 4 to use a SimpleRenderer and Layer 2 to use a ClassBreaksRenderer. The DynamicLayerInfos property is used to add these layers on the fly by setting the Source property to LayerMapSources and a TableDataSource. These properties are applied as the map loads.
Download Sample Application<UserControl x:Class="ArcGISWPFSDK.DynamicLayersInXAML" 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="#FFE3E3E3"> <esri:Map x:Name="MyMap"> <esri:Map.Extent> <esri:Envelope XMin="-3170138" YMin="-1823795" XMax="2850785" YMax="1766663"> <esri:Envelope.SpatialReference> <esri:SpatialReference WKID="102009"/> </esri:Envelope.SpatialReference> </esri:Envelope> </esri:Map.Extent> <esri:ArcGISDynamicMapServiceLayer ID="USA" Url="http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer" VisibleLayers="0,2,4"> <esri:ArcGISDynamicMapServiceLayer.LayerDefinitions> <esri:LayerDefinition LayerID="0" Definition="CAPITAL = 'Y'" /> </esri:ArcGISDynamicMapServiceLayer.LayerDefinitions> <esri:ArcGISDynamicMapServiceLayer.LayerDrawingOptions> <esri:LayerDrawingOptionsCollection> <esri:LayerDrawingOptions LayerID="0" ShowLabels="True"> <esri:LayerDrawingOptions.Renderer> <esri:SimpleRenderer> <esri:SimpleMarkerSymbol Color="Red" Size="10" Style="Diamond" /> </esri:SimpleRenderer> </esri:LayerDrawingOptions.Renderer> </esri:LayerDrawingOptions> <esri:LayerDrawingOptions LayerID="2"> <esri:LayerDrawingOptions.Renderer> <esri:ClassBreaksRenderer Field="POP2000"> <esri:ClassBreakInfo MaximumValue="1000000" MinimumValue="0"> <esri:SimpleFillSymbol BorderThickness="1" Fill="#74E01B" BorderBrush="Transparent" /> </esri:ClassBreakInfo> <esri:ClassBreakInfo MaximumValue="2000000"> <esri:SimpleFillSymbol BorderThickness="1" Fill="#1BE025" BorderBrush="Transparent" /> </esri:ClassBreakInfo> <esri:ClassBreakInfo MaximumValue="5000000"> <esri:SimpleFillSymbol BorderThickness="1" Fill="#1BE087" BorderBrush="Transparent" /> </esri:ClassBreakInfo> <esri:ClassBreakInfo MaximumValue="10000000"> <esri:SimpleFillSymbol BorderThickness="1" Fill="#D6E01B" BorderBrush="Transparent" /> </esri:ClassBreakInfo> <esri:ClassBreakInfo MaximumValue="40000000"> <esri:SimpleFillSymbol BorderThickness="1" Fill="#E0871B" BorderBrush="Transparent" /> </esri:ClassBreakInfo> </esri:ClassBreaksRenderer> </esri:LayerDrawingOptions.Renderer> </esri:LayerDrawingOptions> <esri:LayerDrawingOptions LayerID="4"> <esri:LayerDrawingOptions.Renderer> <esri:SimpleRenderer> <esri:SimpleFillSymbol Fill="Blue" BorderBrush="Black" /> </esri:SimpleRenderer> </esri:LayerDrawingOptions.Renderer> </esri:LayerDrawingOptions> </esri:LayerDrawingOptionsCollection> </esri:ArcGISDynamicMapServiceLayer.LayerDrawingOptions> <esri:ArcGISDynamicMapServiceLayer.DynamicLayerInfos> <esri:DynamicLayerInfoCollection> <esri:DynamicLayerInfo ID="0"> <esri:DynamicLayerInfo.Source> <esri:LayerMapSource MapLayerID="0" /> </esri:DynamicLayerInfo.Source> </esri:DynamicLayerInfo> <esri:DynamicLayerInfo ID="4"> <esri:DynamicLayerInfo.Source> <esri:LayerDataSource> <esri:LayerDataSource.DataSource> <esri:TableDataSource WorkspaceID="MyDatabaseWorkspaceIDSSR2" DataSourceName="ss6.gdb.Lakes" /> </esri:LayerDataSource.DataSource> </esri:LayerDataSource> </esri:DynamicLayerInfo.Source> </esri:DynamicLayerInfo> <esri:DynamicLayerInfo ID="2"> <esri:DynamicLayerInfo.Source> <esri:LayerMapSource MapLayerID="2" /> </esri:DynamicLayerInfo.Source> </esri:DynamicLayerInfo> </esri:DynamicLayerInfoCollection> </esri:ArcGISDynamicMapServiceLayer.DynamicLayerInfos> </esri:ArcGISDynamicMapServiceLayer> </esri:Map> </Grid> </UserControl>
5/16/2014