ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / Layer Class / SetVisibility Method
Visible.
Example

In This Topic
    SetVisibility Method
    In This Topic
    Sets the layer visibility. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Sub SetVisibility( _
       ByVal isVisible As Boolean _
    ) 
    public void SetVisibility( 
       bool isVisible
    )

    Parameters

    isVisible
    Visible.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Change layer visibility, editability, snappability
    {
        if (!layer.IsVisible)
            layer.SetVisibility(true);
    
        if (layer is FeatureLayer featureLayerToChange)
        {
            if (!featureLayer.IsEditable)
                featureLayer.SetEditable(true);
    
            if (!featureLayer.IsSnappable)
                featureLayer.SetSnappable(true);
        }
    }
    Create Stream Layer with URI
    {
      // Note: call within QueuedTask.Run()
      {
        var url = "https://geoeventsample1.esri.com:6443/arcgis/rest/services/AirportTraffics/StreamServer";
        var createParam = new FeatureLayerCreationParams(new Uri(url))
        {
          IsVisible = false //turned off by default
        };
        streamLayer = LayerFactory.Instance.CreateLayer<StreamLayer>(createParam, map);
    
        //or use "original" create layer (will be visible by default)
        Uri uri = new Uri(url);
        streamLayer = LayerFactory.Instance.CreateLayer(uri, map) as StreamLayer;
        streamLayer.SetVisibility(false);//turn off
      }
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also