ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / FeatureLayer Class / IsSnappable Property
Example

In This Topic
    IsSnappable Property (FeatureLayer)
    In This Topic
    Gets whether feature snapping is enabled.
    Syntax
    Public ReadOnly Property IsSnappable As Boolean
    public bool IsSnappable {get;}
    Example
    Configure Snapping - Layer Snappability
    var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault();
    // is the layer snappable?
    bool isSnappable = featureLayer.IsSnappable;
    // set snappability for a specific layer - needs to run on the MCT
    await QueuedTask.Run(() =>
    {
      // use an extension method
      featureLayer.SetSnappable(true);
    
      // or use the CIM directly
      //var layerDef = fLayer.GetDefinition() as ArcGIS.Core.CIM.CIMGeoFeatureLayerBase;
      //layerDef.Snappable = true;
      //fLayer.SetDefinition(layerDef);
    });
    // turn all layers snappability off
    var layerList = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>();
    await QueuedTask.Run(() =>
    {
      foreach (var layer in layerList)
      {
        layer.SetSnappable(false);
      }
    });
    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);
        }
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also