ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / FeatureLayer Class / GetUseSymbolLayerDrawing Method
Example

In This Topic
    GetUseSymbolLayerDrawing Method (FeatureLayer)
    In This Topic
    Gets whether the layer or a parent group layer is currently using Symbol Layer Drawing or not. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public ValueTuple<bool,bool> GetUseSymbolLayerDrawing()
    Public Function GetUseSymbolLayerDrawing() As ValueTuple(Of Boolean,Boolean)

    Return Value

    Returns a tuple(useOnLayer, useOnParent). useOnLayer will be true if the feature layer is currently using SLD. useOnParent will be true if a parent group layer is currently using SLD (and useOnLayer will be false).
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    SLD has not been added to this layer or a parent
    Remarks
    Calling GetUseSymbolLayerDrawing() on a feature layer that does not have SLD added or SLD added to a parent group layer will throw an System.InvalidOperationException. Use HasSymbolLayerDrawingAdded to determine if the feature layer has SLD added.
    The tuple returns two values (useOnLayer, useOnParent). useOnLayer will always be false for a feature layer that participates in a group layer using SLD. The group layer will control SLD for all participating child feature layers.
    Example
    Enable/Disable SLD
    QueuedTask.Run(() =>
    {
      //A layer may have SLD added but is not using it
      //HasSymbolLayerDrawingAdded returns a tuple - to check
      //the layer has SLD (not its parent) check addedOnLayer
      if (featLayer.HasSymbolLayerDrawingAdded().addedOnLayer)
      {
        //the layer has SLD but is the layer currently using it?
        //GetUseSymbolLayerDrawing returns a tuple - useOnLayer for 
        //the layer (and useOnParent for the parent layer)
        if (!featLayer.GetUseSymbolLayerDrawing().useOnLayer)
        {
          //enable it
          featLayer.SetUseSymbolLayerDrawing(true);
        }
      }
    
      //Enable/Disable SLD on a layer parent
      if (featLayer.HasSymbolLayerDrawingAdded().addedOnParent)
      {
        //check parent...this can be recursive
        var parent = GetParentLayerWithSLD(featLayer.Parent as GroupLayer);
        if (parent.GetUseSymbolLayerDrawing().useOnLayer)
          parent.SetUseSymbolLayerDrawing(true);
      }
      /*
       * 
       //Recursively get the parent with SLD
       public GroupLayer GetParentLayerWithSLD(GroupLayer groupLayer) 
       {
         if (groupLayer == null)
           return null;
         //Must be on QueuedTask
         var sld_added = groupLayer.HasSymbolLayerDrawingAdded();
         if (sld_added.addedOnLayer)
           return groupLayer;
         else if (sld_added.addedOnParent)
           return GetParentLayerWithSLD(groupLayer.Parent as GroupLayer);
         return null;
       }
      */
    });
    
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also