ArcGIS Runtime SDK for WPF - Library Reference
LayerDrawingOptionsCollection Class
Members  Example  See Also 
ESRI.ArcGIS.Client Namespace : LayerDrawingOptionsCollection Class

Collection of LayerDrawingOptions which are used to construct a Dynamic Layer.

Object Model

LayerDrawingOptionsCollection ClassLayerDrawingOptions Class

Syntax

Visual Basic (Declaration) 
Public NotInheritable Class LayerDrawingOptionsCollection 
   Inherits System.Collections.ObjectModel.ObservableCollection(Of LayerDrawingOptions)
C# 
public sealed class LayerDrawingOptionsCollection : System.Collections.ObjectModel.ObservableCollection<LayerDrawingOptions> 

Remarks

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

Dynamic Layers are new in ArcGIS Server v10.1 and require the ArcGIS Runtime SDK 1.0 for WPF and higher.

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 LayerDrawingOptionsCollection) 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 (see the code example in the LayerDrawingOptionsCollection Class).

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 both ArcGIS Server v10.1 and higher and the development frameworks of ArcGIS Runtime SDK 1.0 for WPF and higher; use the ArcGISDynamicMapServiceLayer.SupportsDynamicLayers Property to ensure that these conditions have been met.

Example

How to use:

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.

The XAML code in this example is used in conjunction with the code-behind (C# or VB.NET) to demonstrate the functionality.

The following screen shot corresponds to the code example in this page.

Applying different Rendering of a Dynamic Layer.

XAMLCopy Code
<Grid x:Name="LayoutRoot">
  
  <!-- Add a Map Control. Zoom to the Continental United States. -->
  <esri:Map Background="White" HorizontalAlignment="Left" Margin="0,180,0,0" Name="Map1" 
      VerticalAlignment="Top" Height="350" Width="550" Extent="-14070971,2468307,-7345298,6748281">
  
    <!--Add a backdrop ArcGISTiledMapServiceLayer. -->
    <esri:ArcGISTiledMapServiceLayer ID="myArcGISTiledMapServiceLayer" 
       Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" />
  
    <!-- Add an ArcGISDynamicMapServiceLayer to the Map but DO NOT display it.. -->
    <esri:ArcGISDynamicMapServiceLayer ID="myArcGISDynamicMapServiceLayer"
       Url="http://servicesbeta4.esri.com/arcgis/rest/services/USA/MapServer" 
       Visible="False"/>
  
  </esri:Map>
  
  <!-- 
  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="0,110,0,0" 
      HorizontalAlignment="Left"  Name="RadioButton_ExistingRendering" VerticalAlignment="Top" Width="550" IsChecked="True"/>
  <RadioButton Content="Use a new Rendering defined on the client" Height="16" HorizontalAlignment="Left" 
      Margin="0,132,250,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="0,151,0,0" Name="Button1" VerticalAlignment="Top" Width="550" 
      Click="Button1_Click"/>
  
  <!-- Provide the instructions on how to use the sample code. -->
  <TextBlock Height="75" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" Width="788" 
     TextWrapping="Wrap" 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." />
</Grid>
C#Copy Code
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.ArcGIS.Client.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)(Map1.Layers["myArcGISDynamicMapServiceLayer"]);
  
  // Create a new DynamicLayerInfoCollection based upon the existing ArcGISDynamicMapServiceLayer.
  ESRI.ArcGIS.Client.DynamicLayerInfoCollection myDynamicLayerInfoCollection = myArcGISDynamicMapServiceLayer.CreateDynamicLayerInfosFromLayerInfos; //myCREATED_DynamicLayerInfoCollection
  
  // Loop through each DynamicLayerInfo object (i.e. sub-layer information about the ArcGISDynamicMapServiceLayer)
  foreach (ESRI.ArcGIS.Client.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.ArcGIS.Client.LayerSource myLayerSource = myDynamicLayerInfo.Source;
    if (myLayerSource is ESRI.ArcGIS.Client.LayerMapSource)
    {
      // We are only interested in the 'Counties' sub-layer for this sample code.
      if (myName == "egdb.DBADMIN.USCounties ")
      {
        // Create a new DynamicLayerInfo object (i.e. the container for the new Dynamic Layer)
        ESRI.ArcGIS.Client.DynamicLayerInfo newDynamicLayerInfo = new ESRI.ArcGIS.Client.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.ArcGIS.Client.DynamicLayerInfoCollection newDynamicLayerInfoCollection = new ESRI.ArcGIS.Client.DynamicLayerInfoCollection();
        newDynamicLayerInfoCollection.Add(newDynamicLayerInfo);
        
        // Create a new Dynamic Layer that is based upon the 'Counties' sub-layer of the ArcGISDynamicMapServiceLayer.
        ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer newArcGISDynamicMapServiceLayer = new ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer();
        newArcGISDynamicMapServiceLayer.Url = myArcGISDynamicMapServiceLayer.Url;
        newArcGISDynamicMapServiceLayer.DisableClientCaching = true;
        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 solid Yellow brush that is 50% transparent.
          System.Windows.Media.SolidColorBrush tmpSolidColorBrush = new System.Windows.Media.SolidColorBrush(Colors.Yellow);
          tmpSolidColorBrush.Opacity = 0.5;
          
          // Create a SimpleFillSymbol using the solid Yellow brush and set the Border to be Red with a thickness of 1.
          ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol newSimpleFillSymbol = new ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol();
          newSimpleFillSymbol.Fill = tmpSolidColorBrush;
          newSimpleFillSymbol.BorderBrush = new System.Windows.Media.SolidColorBrush(Colors.Red);
          newSimpleFillSymbol.BorderThickness = 1;
          
          // Create a new SimpleRenderer based up the SimpleFillSymbol.
          ESRI.ArcGIS.Client.SimpleRenderer newSimpleRenderer = new ESRI.ArcGIS.Client.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.ArcGIS.Client.LayerDrawingOptions newLayerDrawingOptions = new ESRI.ArcGIS.Client.LayerDrawingOptions();
          newLayerDrawingOptions.LayerID = myID;
          newLayerDrawingOptions.Renderer = newSimpleRenderer;
          
          // Create a new LayerDrawinOptionsCollection and add the LayerDraingOptions object into it.
          ESRI.ArcGIS.Client.LayerDrawingOptionsCollection newLayerDrawingOptionsCollection = new ESRI.ArcGIS.Client.LayerDrawingOptionsCollection();
          newLayerDrawingOptionsCollection.Add(newLayerDrawingOptions);
          
          // Apply the custom Rendering for the Dynamic Layer.
          newArcGISDynamicMapServiceLayer.LayerDrawingOptions = newLayerDrawingOptionsCollection;
        }
        // Add the Dynamic Layer to the Map Control. This causes the round trip server request to occur.
        Map1.Layers.Add(newArcGISDynamicMapServiceLayer);
      }
    }
  }
}
VB.NETCopy Code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
  
  ' Get the ArcGISDynamicMapServiceLayer that was defined in XAML but not shown visually in the Map.
  Dim myArcGISDynamicMapServiceLayer As ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer = CType(Map1.Layers("myArcGISDynamicMapServiceLayer"), ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)
  
  ' Create a new DynamicLayerInfoCollection based upon the existing ArcGISDynamicMapServiceLayer.
  Dim myDynamicLayerInfoCollection As ESRI.ArcGIS.Client.DynamicLayerInfoCollection = myArcGISDynamicMapServiceLayer.CreateDynamicLayerInfosFromLayerInfos 'myCREATED_DynamicLayerInfoCollection
  
  ' Loop through each DynamicLayerInfo object (i.e. sub-layer information about the ArcGISDynamicMapServiceLayer)
  For Each myDynamicLayerInfo As ESRI.ArcGIS.Client.DynamicLayerInfo In myDynamicLayerInfoCollection
  
    ' Get the ID of the sub-layer.
    Dim myID As Integer = myDynamicLayerInfo.ID
    
    ' Get the name of the sub-layer.
    Dim myName As String = myDynamicLayerInfo.Name
    
    ' Get the LayerSource object of the sub-layer. It will be a LayerMapSource Type because it is based on a 
    ' published ArcGISDynamicMapServiceLayer.
    Dim myLayerSource As ESRI.ArcGIS.Client.LayerSource = myDynamicLayerInfo.Source
    If TypeOf myLayerSource Is ESRI.ArcGIS.Client.LayerMapSource Then
    
      ' We are only interested in the 'Counties' sub-layer for this sample code.
      If myName = "egdb.DBADMIN.USCounties " Then
        
        ' Create a new DynamicLayerInfo object (i.e. the container for the new Dynamic Layer)
        Dim newDynamicLayerInfo As New ESRI.ArcGIS.Client.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.
        Dim newDynamicLayerInfoCollection As New ESRI.ArcGIS.Client.DynamicLayerInfoCollection
        newDynamicLayerInfoCollection.Add(newDynamicLayerInfo)
        
        ' Create a new Dynamic Layer that is based upon the 'Counties' sub-layer of the ArcGISDynamicMapServiceLayer.
        Dim newArcGISDynamicMapServiceLayer As New ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer
        newArcGISDynamicMapServiceLayer.Url = myArcGISDynamicMapServiceLayer.Url
        newArcGISDynamicMapServiceLayer.DisableClientCaching = True
        newArcGISDynamicMapServiceLayer.DynamicLayerInfos = newDynamicLayerInfoCollection
        
        ' Allow the user to decide how they was the new Dynamic Layer Rendered.
        If RadioButton_ExistingRendering.IsChecked = True Then
          
          ' 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.
          
        ElseIf RadioButton_NewRendering.IsChecked = True Then
          
          ' Use Rendering that is defined here on the client-side.
          
          ' Create a solid Yellow brush that is 50% transparent.
          Dim tmpSolidColorBrush As New System.Windows.Media.SolidColorBrush(Colors.Yellow)
          tmpSolidColorBrush.Opacity = 0.5
          
          ' Create a SimpleFillSymbol using the solid Yellow brush and set the Border to be Red with a thickness of 1.
           Dim newSimpleFillSymbol As New ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol
          newSimpleFillSymbol.Fill = tmpSolidColorBrush
          newSimpleFillSymbol.BorderBrush = New System.Windows.Media.SolidColorBrush(Colors.Red)
          newSimpleFillSymbol.BorderThickness = 1
          
          ' Create a new SimpleRenderer based up the SimpleFillSymbol.
          Dim newSimpleRenderer As New ESRI.ArcGIS.Client.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.
          Dim newLayerDrawingOptions As New ESRI.ArcGIS.Client.LayerDrawingOptions
          newLayerDrawingOptions.LayerID = myID
          newLayerDrawingOptions.Renderer = newSimpleRenderer
          
          ' Create a new LayerDrawinOptionsCollection and add the LayerDraingOptions object into it.
          Dim newLayerDrawingOptionsCollection As New ESRI.ArcGIS.Client.LayerDrawingOptionsCollection
          newLayerDrawingOptionsCollection.Add(newLayerDrawingOptions)
          
          ' Apply the custom Rendering for the Dynamic Layer.
          newArcGISDynamicMapServiceLayer.LayerDrawingOptions = newLayerDrawingOptionsCollection
          
        End If
        
        ' Add the Dynamic Layer to the Map Control. This causes the round trip server request to occur.
        Map1.Layers.Add(newArcGISDynamicMapServiceLayer)
        
      End If
      
    End If
    
  Next
  
End Sub

Inheritance Hierarchy

System.Object
   System.Collections.ObjectModel.Collection<T>
      System.Collections.ObjectModel.ObservableCollection<T>
         ESRI.ArcGIS.Client.LayerDrawingOptionsCollection

Requirements

Target Platforms: Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7, Windows 8

See Also

© ESRI, Inc. All Rights Reserved.