<?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: Does a component exist to retrieve existing layers from map? in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/does-a-component-exist-to-retrieve-existing-layers/m-p/1242200#M9196</link>
    <description>&lt;P&gt;There's nothing "built-in" but we have lots of examples of combos in panes, dockpanes, etc. that list the names of layers from the map, etc. in the samples.&lt;/P&gt;&lt;P&gt;Here's one u can look at that should help get u started:&amp;nbsp;&lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Authoring/LayersPane" target="_blank"&gt;https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Authoring/LayersPane&lt;/A&gt;&amp;nbsp;-&amp;nbsp;Specifically, look at the layers pane combobox implementation in&amp;nbsp;&lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples/blob/master/Map-Authoring/LayersPane/UI/LayersPane.xaml" target="_blank"&gt;https://github.com/Esri/arcgis-pro-sdk-community-samples/blob/master/Map-Authoring/LayersPane/UI/LayersPane.xaml&lt;/A&gt;. It is bound to a property "AllMapLayers" in the view model. It is just showing feature layers but u can change that to be whichever layer types - as you need.&lt;/P&gt;&lt;P&gt;There are probably others.&lt;/P&gt;</description>
    <pubDate>Sat, 17 Dec 2022 01:02:14 GMT</pubDate>
    <dc:creator>CharlesMacleod</dc:creator>
    <dc:date>2022-12-17T01:02:14Z</dc:date>
    <item>
      <title>Does a component exist to retrieve existing layers from map?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/does-a-component-exist-to-retrieve-existing-layers/m-p/1242197#M9194</link>
      <description>&lt;P&gt;I'm working on an Add-In and need to be able to use layers that are currently added in the Map's content pane. I would like to see if there is a ProSnippet that lets me directly add this component. The component that I would like to use looks like this and I see it all around ArcGIS Pro. It also lets you use geometry that you create on-the-fly.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KevinCheriyan_0-1671235337304.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/58819i77646FC416D8BAEB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KevinCheriyan_0-1671235337304.png" alt="KevinCheriyan_0-1671235337304.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The closest thing I could find was using a ComboBox in combination with Map class's &lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic11875.html" target="_self"&gt;GetLayersAsFlattenedList&amp;nbsp;&lt;/A&gt;method. But this still leaves a lot of functionality missing from the component I would've like to use.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Dec 2022 00:09:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/does-a-component-exist-to-retrieve-existing-layers/m-p/1242197#M9194</guid>
      <dc:creator>KevinCheriyan</dc:creator>
      <dc:date>2022-12-17T00:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: Does a component exist to retrieve existing layers from map?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/does-a-component-exist-to-retrieve-existing-layers/m-p/1242200#M9196</link>
      <description>&lt;P&gt;There's nothing "built-in" but we have lots of examples of combos in panes, dockpanes, etc. that list the names of layers from the map, etc. in the samples.&lt;/P&gt;&lt;P&gt;Here's one u can look at that should help get u started:&amp;nbsp;&lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Authoring/LayersPane" target="_blank"&gt;https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Authoring/LayersPane&lt;/A&gt;&amp;nbsp;-&amp;nbsp;Specifically, look at the layers pane combobox implementation in&amp;nbsp;&lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples/blob/master/Map-Authoring/LayersPane/UI/LayersPane.xaml" target="_blank"&gt;https://github.com/Esri/arcgis-pro-sdk-community-samples/blob/master/Map-Authoring/LayersPane/UI/LayersPane.xaml&lt;/A&gt;. It is bound to a property "AllMapLayers" in the view model. It is just showing feature layers but u can change that to be whichever layer types - as you need.&lt;/P&gt;&lt;P&gt;There are probably others.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Dec 2022 01:02:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/does-a-component-exist-to-retrieve-existing-layers/m-p/1242200#M9196</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2022-12-17T01:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: Does a component exist to retrieve existing layers from map?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/does-a-component-exist-to-retrieve-existing-layers/m-p/1244633#M9215</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/145101"&gt;@CharlesMacleod&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Thank you for this solution. This answers my original question. Playing with this further, however, the LayersPane Combobox does not update when a new layer is added. The way AllMapLayers is bound to the ComboBox ItemsSource property, does it not allow automatic updating? I also used the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic12661.html" target="_self"&gt;LayersAddedEvent,&lt;/A&gt;&amp;nbsp;by running the following when triggered.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;_allMapLayers = activeView.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().ToList();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While this does actually update the _allMapLayers variable (I was able to verify using a Dialogs.MessageBox which displayed total layer count in the map), it doesn't update the combobox on-the-fly. The LayersPane sample you provided doesn't have this functionality either.&lt;/P&gt;&lt;P&gt;What's the best remedy here?&lt;/P&gt;&lt;P&gt;Thanks for your time!&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 19:56:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/does-a-component-exist-to-retrieve-existing-layers/m-p/1244633#M9215</guid>
      <dc:creator>KevinCheriyan</dc:creator>
      <dc:date>2022-12-30T19:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: Does a component exist to retrieve existing layers from map?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/does-a-component-exist-to-retrieve-existing-layers/m-p/1244667#M9216</link>
      <description>&lt;P&gt;Yes, things can get complicated quickly. If you need your combo to remain current "auto-magically" as the map TOC changes you will need to handle all events associated with changes to the TOC.&lt;/P&gt;&lt;P&gt;Start with:&lt;/P&gt;&lt;P&gt;ArcGIS.Desktop.Mapping.Events.LayersAddedEvent&lt;/P&gt;&lt;P&gt;ArcGIS.Desktop.Mapping.Events.LayersRemovedEvent&lt;/P&gt;&lt;P&gt;In each of these add or remove the relevant layer(s) to your list&lt;/P&gt;&lt;P&gt;If the user can switch (active) maps, then you will need to handle this one also:&lt;/P&gt;&lt;P&gt;ArcGIS.Desktop.Mapping.Events.ActiveMapViewChangedEvent.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It will fire twice when a map pane switches - once when the (old) view is deactivated and once when the new view is activated. If a user selects a Layout/Chart/or other non-map pane then it fires just once (for the old view being deactivated).&lt;/P&gt;&lt;P&gt;For "automatic" updating, as u call it, u would need an ObservableCollection and not a (generic) List. However, switching to an ObservableCollection will require u to handle the multi-threaded access (from the UI and, potentially, from the QueuedTask) which adds another level of complexity. (fyi This was covered at Dev Summit 2022 here:&amp;nbsp;&lt;A href="https://esri.github.io/arcgis-pro-sdk/techsessions/2022/PalmSprings/ImprovingYourDockpaneandProWindow.zip" target="_blank"&gt;https://esri.github.io/arcgis-pro-sdk/techsessions/2022/PalmSprings/ImprovingYourDockpaneandProWindow.zip)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 22:10:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/does-a-component-exist-to-retrieve-existing-layers/m-p/1244667#M9216</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2022-12-30T22:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: Does a component exist to retrieve existing layers from map?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/does-a-component-exist-to-retrieve-existing-layers/m-p/1247831#M9279</link>
      <description>&lt;P&gt;i attached a small sample that worked for me.&amp;nbsp; With 3.1 this will be added to Community Samples.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2023 21:14:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/does-a-component-exist-to-retrieve-existing-layers/m-p/1247831#M9279</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2023-01-12T21:14:32Z</dc:date>
    </item>
  </channel>
</rss>

