ArcGIS Pro 2.9 API Reference Guide
GetTemplate(Layer,String) Method
Example 

ArcGIS.Desktop.Mapping Namespace > MappingExtensions Class > GetTemplate Method : GetTemplate(Layer,String) Method
the layer containing the template.
the name of the template to be retrieved.
Gets a template by name for a layer. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
public static EditingTemplate GetTemplate( 
   Layer layer,
   string name
)
Public Overloads Shared Function GetTemplate( _
   ByVal layer As Layer, _
   ByVal name As String _
) As EditingTemplate

Parameters

layer
the layer containing the template.
name
the name of the template to be retrieved.

Return Value

the template. Null if the template doesn't exist on the layer.
Exceptions
ExceptionDescription
This method or property must be called within the lambda passed to QueuedTask.Run.
Example
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
  //get the templates
  var map = ArcGIS.Desktop.Mapping.MapView.Active.Map;
  if (map == null)
    return;

  var mainTemplate = map.FindLayers("main").FirstOrDefault()?.GetTemplate("Distribution");
  var mhTemplate = map.FindLayers("Manhole").FirstOrDefault()?.GetTemplate("Active");
});
Requirements

Target Platforms: Windows 11, Windows 10, Windows 8.1

See Also

Reference

MappingExtensions Class
MappingExtensions Members
Overload List