ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Editing.Templates Namespace / EditingTemplate Class / ActivateToolAsync Method
DAML ID of the Tool
Example

In This Topic
    ActivateToolAsync Method
    In This Topic
    Activates a Tool that is identified by the given ID.
    Syntax
    Public Function ActivateToolAsync( _
       ByVal damlID As String _
    ) As Task
    public Task ActivateToolAsync( 
       string damlID
    )

    Parameters

    damlID
    DAML ID of the Tool
    Example
    Activate template and a specific editing tool
    {
      await QueuedTask.Run(() =>
      {
        // DAML ID of the tool to activate - for example "esri_editing_SketchTwoPointLineTool" Pro Tool or a custom tool
        string _editToolname = "esri_editing_SketchTwoPointLineTool";
    
        // Get all templates for the layer
        var templates = featureLayer.GetTemplates();
        if (templates.Count == 0)
          return;
        // Get the first template - alternatively get a specific template
        var template = templates.First();
    
        // Confirm the tool is available in the template
        if (template.ToolIDs.FirstOrDefault(_editToolname) == null)
          return;
    
        // Activate the tool
        template.ActivateToolAsync(_editToolname);
      });
    }
    Active Template Changed
    // Subscribes to the active template changed event and handles changes to the editing template.
    ArcGIS.Desktop.Editing.Events.ActiveTemplateChangedEvent.Subscribe(async activeTemplateChangedEventArgs
      =>
    {
      // return if incoming template is null
      if (activeTemplateChangedEventArgs.IncomingTemplate == null)
        return;
    
      // Activate two-point line tool for Freeway template in the Layers map
      if (activeTemplateChangedEventArgs.IncomingTemplate.Name == "Freeway" && activeTemplateChangedEventArgs.IncomingMapView.Map.Name == "Layers")
        await activeTemplateChangedEventArgs.IncomingTemplate.ActivateToolAsync("esri_editing_SketchTwoPointLineTool");
    });
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also