Click or drag to resize
LayerDrawingOptionCollection Class
A collection of LayerDrawingOptions used with the ArcGISDynamicMapServiceLayer.
Inheritance Hierarchy

Namespace: Esri.ArcGISRuntime.Layers
Assembly: Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: (
public class LayerDrawingOptionCollection : ObservableCollection<LayerDrawingOptions>

The LayerDrawingOptionCollection type exposes the following members.

Public methodAdd (Inherited from CollectionLayerDrawingOptions.)
Protected methodBlockReentrancy
Disallows reentrant attempts to change this collection.
(Inherited from ObservableCollectionLayerDrawingOptions.)
Protected methodCheckReentrancy
Checks for reentrant attempts to change this collection.
(Inherited from ObservableCollectionLayerDrawingOptions.)
Public methodClear (Inherited from CollectionLayerDrawingOptions.)
Protected methodClearItems
Clears the items.
(Overrides ObservableCollectionTClearItems.)
Public methodContains (Inherited from CollectionLayerDrawingOptions.)
Public methodCopyTo (Inherited from CollectionLayerDrawingOptions.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetEnumerator (Inherited from CollectionLayerDrawingOptions.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIndexOf (Inherited from CollectionLayerDrawingOptions.)
Public methodInsert (Inherited from CollectionLayerDrawingOptions.)
Protected methodInsertItem
Inserts an item into the collection at the specified index.
(Inherited from ObservableCollectionLayerDrawingOptions.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodMove
Moves the item at the specified index to a new location in the collection.
(Inherited from ObservableCollectionLayerDrawingOptions.)
Protected methodMoveItem
Moves the item at the specified index to a new location in the collection.
(Inherited from ObservableCollectionLayerDrawingOptions.)
Protected methodOnCollectionChanged
Raises the CollectionChanged event.
(Overrides ObservableCollectionTOnCollectionChanged(NotifyCollectionChangedEventArgs).)
Protected methodOnPropertyChanged
Raises the PropertyChanged event with the provided arguments.
(Inherited from ObservableCollectionLayerDrawingOptions.)
Public methodRemove (Inherited from CollectionLayerDrawingOptions.)
Public methodRemoveAt (Inherited from CollectionLayerDrawingOptions.)
Protected methodRemoveItem
Removes the item at the specified index of the collection.
(Inherited from ObservableCollectionLayerDrawingOptions.)
Protected methodSetItem
Replaces the element at the specified index.
(Inherited from ObservableCollectionLayerDrawingOptions.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public propertyCount (Inherited from CollectionLayerDrawingOptions.)
Public propertyItem
Gets or sets the element at the specified index.
(Inherited from CollectionLayerDrawingOptions.)
Protected propertyItems (Inherited from CollectionLayerDrawingOptions.)
Public eventCollectionChanged
Occurs when an item is added, removed, changed, moved, or the entire list is refreshed.
(Inherited from ObservableCollectionLayerDrawingOptions.)
Protected eventPropertyChanged
Occurs when a property value changes.
(Inherited from ObservableCollectionLayerDrawingOptions.)

Dynamic Layers allow the execution of various ArcGIS Server requests from a client application. An in-depth discussion about Dynamic Layers is in the Fundamentals document: Dynamic Layers. The client side requests that can be issued to ArcGIS Server include the ability to:

  • Change the rendering of an existing ArcGISDynamicMapServiceLayer.
  • Create a layer on-the-fly for the Workspace Types of: Database, Shapefile, FileGDB, and Raster.
  • Perform table joins.
  • Query for specific records.
  • Identify features.
  • Return raster images.

Dynamic Layers are new in ArcGIS Server v10.1.

It is necessary for a Dynamic Layer that will be displayed in a Map Control to have the appropriate Rendering applied. The ArcGISDynamicMapServiceLayer.LayerDrawingOptions Property (which is a LayerDrawingOptionCollection Class) is used to set the Rendering of each Dynamic Layer. Like the ArcGISDynamicMapServiceLayer.DynamicLayerInfos Property, the ArcGISDynamicMapServiceLayer.LayerDrawingOptions Property is also empty (meaning Nothing/null) when an ArcGISDynamicMapServiceLayer is created in ArcMap and served up via ArcGIS Server.

There is not a specific Method to generate a LayerDrawingOptionsCollection that is pre-populated with existing Rendering options of the sub-layers in an ArcGISDynamicMapServiceLayer similar to the ArcGISDynamicMapServiceLayer.CreateDynamicLayerInfosFromLayerInfos Method. In order create a new Dynamic Layer using the Rendering of a sub-layer that already exists in an ArcGISDynamicMapServiceLayer, one only needs to specify the DynamicLayerInfo.Source to that of an existing LayerMapSource object.

When creating a new Dynamic Layer and specifying a custom Rendering make sure that the LayerDrawingOptions.LayerID and DynamicLayerInfo.ID match in order for the Dynamic Layer to draw in the Map.

NOTE: Because creating and using Dynamic Layers requires ArcGIS Server v10.1 and higher, use the ArcGISDynamicMapServiceLayer.ServiceInfo Property to obtain a MapServiceInfo object. Then check that the MapServiceInfo.SupportsDynamicLayers Property = True to ensure that these conditions have been met.


Demonstrates using the existing rendering of a Dynamic Layer sub-layer of an ArcGISDynamicMapServiceLayer and switching to a custom rendering defined in code-behind for the Dynamic Layer.

Code example using the LayerDrawingOptionCollection Class.

<Window x:Class="LayerDrawingOptionCollection.MainWindow"
        Title="MainWindow" Height="600" Width="800">

    <Grid x:Name="LayoutRoot" Margin="0,0,0,-3">

        <!-- Add a MapView Control. -->
        <esri:MapView x:Name="MapView1" Background="White" HorizontalAlignment="Left" Margin="10,129,0,0"
                      VerticalAlignment="Top" Height="434" Width="772">

            <!-- Add a Map. -->
            <esri:Map x:Name="Map1">

                <!--Add a backdrop ArcGISTiledMapServiceLayer. -->
                <esri:ArcGISTiledMapServiceLayer ID="myArcGISTiledMapServiceLayer" 
                    ServiceUri="" />

                <!-- Add an ArcGISDynamicMapServiceLayer to the Map. When the application loads make sure to turn off 
                    the visibility of all of the sub-layers (this will be done in code-behind). -->
                <esri:ArcGISDynamicMapServiceLayer ID="myArcGISDynamicMapServiceLayer" 
                   ServiceUri="" />


        Add a Button to create a Dynamic Layer based upon the 'counties' sub-layer of the ArcGISDynamicMapServiceLayer. 
        Allow the user to choose which type of Rendering to apply to the Dynamic Layer.
        <RadioButton Content="Use existing Rendering defined by the published service" Height="16" Margin="10,58,0,0" 
          HorizontalAlignment="Left"  Name="RadioButton_ExistingRendering" VerticalAlignment="Top" Width="550" IsChecked="True"/>
        <RadioButton Content="Use a new Rendering defined on the client in the code-behind" Height="16" HorizontalAlignment="Left" 
          Margin="10,74,0,0" Name="RadioButton_NewRendering" VerticalAlignment="Top" Width="550" />
        <Button Content="Create a Dynamic Layer from the 'Counties' sub-layer of the ArcGISDynamicMapServiceLayer" Height="23" 
          HorizontalAlignment="Left" Margin="10,101,0,0" Name="Button1" VerticalAlignment="Top" Width="778" 

        <!-- Add a TextBlock to hold the instructions on how to use the sample code. -->
        <TextBlock Height="53" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" Width="772" 
            TextWrapping="Wrap" Margin="10,0,0,0" />


SPECIAL NOTE: The XAML displayed above comes from a C# project. If you are a VB.NET developer, you will need to modify the text for the x:Class namespace from "LayerDrawingOptionCollection.MainWindow" to be just "MainWindow".

namespace LayerDrawingOptionCollection
    public partial class MainWindow : System.Windows.Window
        public MainWindow()

            // Add the instructions on how to use this example code to the TextBlock.
            TextBlock1.Text = "Click the button to add a Dynamic Layer based upon the 'Counties' sub-layer of the " + 
                "ArcGISDynamimcMapServiceLayer. Experiment with the choices for Rendering by trying each of the two radio buttons. " + 
                "One radio button uses the existing Rendering provided by ArcGIS Server service, the other does Rendering based " + 
                "upon the Client request.";

            // Get the ArcGISDynamicMapServiceLayer that was defined in XAML and ensure none of the sub-layers are drawn.
            Esri.ArcGISRuntime.Layers.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = null;
            myArcGISDynamicMapServiceLayer = (Esri.ArcGISRuntime.Layers.ArcGISDynamicMapServiceLayer)(MapView1.Map.Layers["myArcGISDynamicMapServiceLayer"]);
            myArcGISDynamicMapServiceLayer.VisibleLayers = new System.Collections.ObjectModel.ObservableCollection<int>();

            // Zoom to the Continental United States.
            Esri.ArcGISRuntime.Geometry.Envelope myExtent;
            myExtent = new Esri.ArcGISRuntime.Geometry.Envelope(-14070971, 2468307, -7345298, 6748281);
            MapView1.Map.InitialViewpoint = new Esri.ArcGISRuntime.Controls.Viewpoint(myExtent);

        private void Button1_Click(object sender, System.Windows.RoutedEventArgs e)

            // Get the ArcGISDynamicMapServiceLayer that was defined in XAML but not shown visually in the Map.
            Esri.ArcGISRuntime.Layers.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = null;
            myArcGISDynamicMapServiceLayer = (Esri.ArcGISRuntime.Layers.ArcGISDynamicMapServiceLayer)(MapView1.Map.Layers["myArcGISDynamicMapServiceLayer"]);

            // Create a new DynamicLayerInfoCollection based upon the existing ArcGISDynamicMapServiceLayer.
            Esri.ArcGISRuntime.Layers.DynamicLayerInfoCollection myDynamicLayerInfoCollection = null;
            myDynamicLayerInfoCollection = myArcGISDynamicMapServiceLayer.CreateDynamicLayerInfosFromLayerInfos();

            // Loop through each DynamicLayerInfo object (i.e. sub-layer information about the ArcGISDynamicMapServiceLayer)
            foreach (Esri.ArcGISRuntime.Layers.DynamicLayerInfo myDynamicLayerInfo in myDynamicLayerInfoCollection)

                // Get the ID of the sub-layer.
                int myID = myDynamicLayerInfo.ID;

                // Get the name of the sub-layer.
                string myName = myDynamicLayerInfo.Name;

                // Get the LayerSource object of the sub-layer. It will be a LayerMapSource Type because it is based on a 
                // published ArcGISDynamicMapServiceLayer.
                Esri.ArcGISRuntime.Layers.LayerSource myLayerSource = myDynamicLayerInfo.Source;
                if (myLayerSource is Esri.ArcGISRuntime.Layers.LayerMapSource)

                    // We are only interested in the 'Counties' sub-layer for this sample code.
                    if (myName == "Counties")

                        // Create a new DynamicLayerInfo object (i.e. the container for the new Dynamic Layer)
                        Esri.ArcGISRuntime.Layers.DynamicLayerInfo newDynamicLayerInfo = new Esri.ArcGISRuntime.Layers.DynamicLayerInfo();

                        // Base the DynamicLayerInfo Properties on what was published in the 'Counties' sub-layer.
                        newDynamicLayerInfo.ID = myID;
                        newDynamicLayerInfo.Source = myLayerSource;

                        // Create a new DynamicLayerInfoCollection and add the DynamicLayerInfo object into it.
                        Esri.ArcGISRuntime.Layers.DynamicLayerInfoCollection newDynamicLayerInfoCollection = new Esri.ArcGISRuntime.Layers.DynamicLayerInfoCollection();

                        // Create a new Dynamic Layer that is based upon the 'Counties' sub-layer of the ArcGISDynamicMapServiceLayer.
                        Esri.ArcGISRuntime.Layers.ArcGISDynamicMapServiceLayer newArcGISDynamicMapServiceLayer = new Esri.ArcGISRuntime.Layers.ArcGISDynamicMapServiceLayer();
                        newArcGISDynamicMapServiceLayer.ServiceUri = myArcGISDynamicMapServiceLayer.ServiceUri;
                        newArcGISDynamicMapServiceLayer.DynamicLayerInfos = newDynamicLayerInfoCollection;

                        // Allow the user to decide how they was the new Dynamic Layer Rendered.
                        if (RadioButton_ExistingRendering.IsChecked == true)

                            // Use the Rendering that is provided by default from the published ArcGIS Server ArcGISDynamicMapServiceLayer.
                            // There is no need to do anything as the Rendering is automatically transferred as part of use the existing
                            // LayerMapSource for the sub-layer.

                        else if (RadioButton_NewRendering.IsChecked == true)

                            // Use Rendering that is defined here on the client-side.

                            // Create a SimpleFillSymbol using the solid Yellow brush and set the Border to be Red with a thickness of 1.
                            Esri.ArcGISRuntime.Symbology.SimpleFillSymbol newSimpleFillSymbol = new Esri.ArcGISRuntime.Symbology.SimpleFillSymbol();
                            newSimpleFillSymbol.Color = System.Windows.Media.Colors.Yellow;
                            newSimpleFillSymbol.Style = Esri.ArcGISRuntime.Symbology.SimpleFillStyle.Solid;
                            Esri.ArcGISRuntime.Symbology.SimpleLineSymbol mySimpleLineSymbol = new Esri.ArcGISRuntime.Symbology.SimpleLineSymbol();
                            mySimpleLineSymbol.Color = System.Windows.Media.Colors.Red;
                            mySimpleLineSymbol.Style = Esri.ArcGISRuntime.Symbology.SimpleLineStyle.Solid;
                            mySimpleLineSymbol.Width = 1;
                            newSimpleFillSymbol.Outline = mySimpleLineSymbol;

                            // Create a new SimpleRenderer based up the SimpleFillSymbol.
                            Esri.ArcGISRuntime.Symbology.SimpleRenderer newSimpleRenderer = new Esri.ArcGISRuntime.Symbology.SimpleRenderer();
                            newSimpleRenderer.Symbol = newSimpleFillSymbol;

                            // Create a new LayerDrawingOptions object which is key to applying our custom Rendering of the Dynamic Layer.
                            // It is imperative that the LayerDrawingOptions.LayerID = DynamicLayerInfo.ID so that the Dynamic Layer draws
                            // using the new symbology.
                            Esri.ArcGISRuntime.Layers.LayerDrawingOptions newLayerDrawingOptions = new Esri.ArcGISRuntime.Layers.LayerDrawingOptions();
                            newLayerDrawingOptions.LayerID = myID;
                            newLayerDrawingOptions.Renderer = newSimpleRenderer;

                            // Create a new LayerDrawinOptionsCollection and add the LayerDraingOptions object into it.
                            Esri.ArcGISRuntime.Layers.LayerDrawingOptionCollection newLayerDrawingOptionsCollection = new Esri.ArcGISRuntime.Layers.LayerDrawingOptionCollection();

                            // Apply the custom Rendering for the Dynamic Layer.
                            newArcGISDynamicMapServiceLayer.LayerDrawingOptions = newLayerDrawingOptionsCollection;


                        // Add the Dynamic Layer to the Map. This causes the round trip server request to occur.




See Also
Supported Platforms
This type is supported on the following ArcGIS Runtime .NET SDK platforms:
Windows Desktop
Windows Phone
Windows Store
Additional Examples
Hyperlink to ExampleDescription
CreateDynamicLayerInfosFromLayerInfosDemonstrates applying a custom rendering via XAML using the Dynamic Layer option of an ArcGISDynamicMapServiceLayer. Also, shows how to use the ArcGISDynamicMapServiceLayer.CreateDynamicLayerInfosFromLayerInfos Method to obtain the original rendering of the layer that was defined in the map service. The CreateDynamicLayerInfosFromLayerInfos is then used to reset the layer back to orignal rendering.
DynamicLayerInfoCollectionDemonstrates using various Renderers on a Dynamic Layer when the 'WorkspaceID' and 'DataSourceName' are known using a TableDataSource.
DynamicLayerInfosDemonstrates using various Renderers on a Dynamic Layer (via XAML and code-behind) when the 'WorkspaceID' and 'DataSourceName' are known using a TableDataSource.
LayerDrawingOptionCollectionDemonstrates using the existing rendering of a Dynamic Layer sub-layer of an ArcGISDynamicMapServiceLayer and switching to a custom rendering defined in code-behind for the Dynamic Layer.
LayerDrawingOptionsDemonstrates changing the rendering of the first sub-layer of an ArcGISDynamicMapServiceLayer using the Dynamic Layer capabilities of ArcGIS Server 10.1 and higher.
QueryTableDataSourceDemonstrates adding a Dynamic Layer via code-behind using a QueryTableDataSource.