ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / WMSSubLayer Class / GetStyleNames Method
Example

In This Topic
    GetStyleNames Method
    In This Topic
    returns the Style names of the WMS sublayer. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Function GetStyleNames() As IReadOnlyList(Of String)
    public IReadOnlyList<string> GetStyleNames()
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Adding and changing styles for WMS Service Layer
    {
        var serverConnection = new CIMInternetServerConnection { URL = "https://spritle.esri.com/arcgis/services/sanfrancisco_sld/MapServer/WMSServer" };
        var connection = new CIMWMSServiceConnection { ServerConnection = serverConnection };
        LayerCreationParams parameters = new LayerCreationParams(connection);
        parameters.MapMemberPosition = MapMemberPosition.AddToBottom;
        //Note: Needs QueuedTask to run
        var compositeLyr = LayerFactory.Instance.CreateLayer<WMSLayer>(parameters, MapView.Active.Map);
        //wms layer in ArcGIS Pro always has a composite layer inside it
        var wmsLayers = compositeLyr.Layers[0] as ServiceCompositeSubLayer;
        //each wms sublayer belongs in that composite layer
        var highwayLayerWMSSub = wmsLayers.Layers[1] as WMSSubLayer;
        //toggling a sublayer's visibility
        if ((highwayLayerWMSSub != null))
        {
            bool visibility = highwayLayerWMSSub.IsVisible;
            highwayLayerWMSSub.SetVisibility(!visibility);
        }
        //applying an existing style to a wms sub layer
        var pizzaLayerWMSSub = wmsLayers.Layers[0] as WMSSubLayer;
        var currentStyles = pizzaLayerWMSSub.GetStyleNames();
        pizzaLayerWMSSub.SetStyleName(currentStyles[1]);
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also