<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Programmatically select template from favorites in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/programmatically-select-template-from-favorites/m-p/1253187#M9375</link>
    <description>&lt;P&gt;Thank you Narelle, I really appreciate it and I am looking forward to working with this future release.&lt;/P&gt;&lt;P&gt;For those interested, my current approach is this:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;static bool SelectFirstTemplateFromFolder(string folderName)
{
	var pane = FrameworkApplication.DockPaneManager.Find(DAML.Dockpane.esri_editing_CreateFeaturesDockPane);
	pane.Activate();
	var paneType = pane.GetType();
	var pi = paneType.GetProperty("SubPanelIndex");
	pi?.SetValue(pane, 0);
	pi?.SetValue(pane, 1); // Switch to Favorites
	pi = paneType.GetProperty("TemplateFoldersVM");
	var templateFoldersVM = pi?.GetValue(pane);
	pi = templateFoldersVM?.GetType().GetProperty("RootFolderChildren");
	if (pi?.GetValue(templateFoldersVM) is IEnumerable col)
	{
		foreach (var item in col)
		{
			var itemType = item.GetType();
			pi = itemType.GetProperty("Name");
			var name = pi.GetValue(item);
			if (Equals(name, folderName))
			{
				pi = itemType.GetProperty("Children");
				if (pi?.GetValue(item) is IEnumerable children)
				{
					var enumerator = children.GetEnumerator();
					if (enumerator.MoveNext())
					{
						var child = enumerator.Current;
						var childType = child.GetType();
						pi = childType.GetProperty("IsSelected");
						pi.SetValue(child, false);
						pi.SetValue(child, true);
						return true;
					}
				}

				break;
			}
		}
	}

	return false;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jan 2023 06:02:39 GMT</pubDate>
    <dc:creator>FridjofSchmidt</dc:creator>
    <dc:date>2023-01-31T06:02:39Z</dc:date>
    <item>
      <title>Programmatically select template from favorites</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/programmatically-select-template-from-favorites/m-p/1252808#M9366</link>
      <description>&lt;P&gt;Hello, I would like to programmatically select a feature editing template from the list of favorites. For example, when the user clicks a button, the list of favorite templates appears and the first item under a certain folder gets selected. Is there a recommended way of doing this?&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 06:08:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/programmatically-select-template-from-favorites/m-p/1252808#M9366</guid>
      <dc:creator>FridjofSchmidt</dc:creator>
      <dc:date>2023-01-31T06:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically select template from favorites</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/programmatically-select-template-from-favorites/m-p/1252813#M9367</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Have you tried&amp;nbsp;GetTemplates method&amp;nbsp; from MappingExtensions?&lt;/P&gt;&lt;P&gt;More info &lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic9977.html" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;There is ArcGIS Pro SDK community sample for choosing template from list:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Editing/TransferAttributes" target="_self"&gt;https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Editing/TransferAttributes&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 12:00:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/programmatically-select-template-from-favorites/m-p/1252813#M9367</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2023-01-30T12:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically select template from favorites</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/programmatically-select-template-from-favorites/m-p/1252830#M9368</link>
      <description>&lt;P&gt;OK, this might be an option, but actually I was planning to go with the existing UI: Selecting a template from the list of favorites so that it appears selected, expands, and activates its default tool.&lt;/P&gt;&lt;P&gt;It seems I can get hold of the TemplateFoldersVM in esri_editing_CreateFeaturesDockPane and its children via reflection, but I'd prefer a supported solution.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 12:57:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/programmatically-select-template-from-favorites/m-p/1252830#M9368</guid>
      <dc:creator>FridjofSchmidt</dc:creator>
      <dc:date>2023-01-30T12:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically select template from favorites</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/programmatically-select-template-from-favorites/m-p/1253161#M9374</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently there is no method in the API to access the set of favorite templates.&amp;nbsp; Access to templates is currently only from a map member (layer or standalone table) using the GetTemplates method.&amp;nbsp; I will add an issue to our backlog to address this in a future release.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Narelle&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 01:22:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/programmatically-select-template-from-favorites/m-p/1253161#M9374</guid>
      <dc:creator>NarelleChedzey</dc:creator>
      <dc:date>2023-01-31T01:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically select template from favorites</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/programmatically-select-template-from-favorites/m-p/1253187#M9375</link>
      <description>&lt;P&gt;Thank you Narelle, I really appreciate it and I am looking forward to working with this future release.&lt;/P&gt;&lt;P&gt;For those interested, my current approach is this:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;static bool SelectFirstTemplateFromFolder(string folderName)
{
	var pane = FrameworkApplication.DockPaneManager.Find(DAML.Dockpane.esri_editing_CreateFeaturesDockPane);
	pane.Activate();
	var paneType = pane.GetType();
	var pi = paneType.GetProperty("SubPanelIndex");
	pi?.SetValue(pane, 0);
	pi?.SetValue(pane, 1); // Switch to Favorites
	pi = paneType.GetProperty("TemplateFoldersVM");
	var templateFoldersVM = pi?.GetValue(pane);
	pi = templateFoldersVM?.GetType().GetProperty("RootFolderChildren");
	if (pi?.GetValue(templateFoldersVM) is IEnumerable col)
	{
		foreach (var item in col)
		{
			var itemType = item.GetType();
			pi = itemType.GetProperty("Name");
			var name = pi.GetValue(item);
			if (Equals(name, folderName))
			{
				pi = itemType.GetProperty("Children");
				if (pi?.GetValue(item) is IEnumerable children)
				{
					var enumerator = children.GetEnumerator();
					if (enumerator.MoveNext())
					{
						var child = enumerator.Current;
						var childType = child.GetType();
						pi = childType.GetProperty("IsSelected");
						pi.SetValue(child, false);
						pi.SetValue(child, true);
						return true;
					}
				}

				break;
			}
		}
	}

	return false;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 06:02:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/programmatically-select-template-from-favorites/m-p/1253187#M9375</guid>
      <dc:creator>FridjofSchmidt</dc:creator>
      <dc:date>2023-01-31T06:02:39Z</dc:date>
    </item>
  </channel>
</rss>

