Parameters
- damlID
- DAML ID of the 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);
});
}
// 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"); });
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)