<?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 Remove legend items from layout when no feature for this layer on the map extent. in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/remove-legend-items-from-layout-when-no-feature/m-p/1087889#M7010</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;In ArcGIS Pro, there is an option in the legendElement from layout to display only legend items when at least one feature is displayed on the map extent (Only show features visible in the map extent).&lt;/P&gt;&lt;P&gt;Is there such an option in the SDK or should I loop through the MapFrame's layer, make a check and then remove the element from the legend.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Wed, 11 Aug 2021 13:33:59 GMT</pubDate>
    <dc:creator>FredB</dc:creator>
    <dc:date>2021-08-11T13:33:59Z</dc:date>
    <item>
      <title>Remove legend items from layout when no feature for this layer on the map extent.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/remove-legend-items-from-layout-when-no-feature/m-p/1087889#M7010</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;In ArcGIS Pro, there is an option in the legendElement from layout to display only legend items when at least one feature is displayed on the map extent (Only show features visible in the map extent).&lt;/P&gt;&lt;P&gt;Is there such an option in the SDK or should I loop through the MapFrame's layer, make a check and then remove the element from the legend.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2021 13:33:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/remove-legend-items-from-layout-when-no-feature/m-p/1087889#M7010</guid>
      <dc:creator>FredB</dc:creator>
      <dc:date>2021-08-11T13:33:59Z</dc:date>
    </item>
    <item>
      <title>Re: Remove legend items from layout when no feature for this layer on the map extent.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/remove-legend-items-from-layout-when-no-feature/m-p/1088028#M7021</link>
      <description>&lt;P&gt;I am assuming u are referring to this setting....&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="auto_visibility.png" style="width: 422px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/20644i4CDB4F7C574B4683/image-size/large?v=v2&amp;amp;px=999" role="button" title="auto_visibility.png" alt="auto_visibility.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;which I am not personally familiar with but...if that _is_ the property u are interested in, with a bit of trial and error, it turns out it is this guy here: &lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/#topic2733.html" target="_self"&gt;CIMLegendItem.AutoVisibility&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This snippet toggles that AutoVisibility for all legend items. I noticed that the legend item property UI did not automatically refresh to reflect the "toggled" value but that is a bug (and I will relay that to the layout team). To update the UI I had to click on the legend and then back on the legend item.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;internal class ToggleAutoVisibility : Button
	{
		protected override void OnClick()
		{
			var lyt = LayoutView.Active?.Layout;
			if (lyt == null)
				return;
			QueuedTask.Run(() =&amp;gt;
			{
				var def = lyt.GetDefinition();
				var legend = def.Elements.OfType&amp;lt;CIMLegend&amp;gt;().FirstOrDefault();
				if (legend != null)
				{
					//toggle auto visibility of all the legend items
					foreach(var leg_item in legend.Items)
					{
						leg_item.AutoVisibility = !leg_item.AutoVisibility;
					}
					//commit the change
					lyt.SetDefinition(def);
				}
			});
		}
	}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2021 17:59:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/remove-legend-items-from-layout-when-no-feature/m-p/1088028#M7021</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2021-08-11T17:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: Remove legend items from layout when no feature for this layer on the map extent.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/remove-legend-items-from-layout-when-no-feature/m-p/1088314#M7025</link>
      <description>&lt;P&gt;That was it. Thanks !&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2021 07:23:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/remove-legend-items-from-layout-when-no-feature/m-p/1088314#M7025</guid>
      <dc:creator>FredB</dc:creator>
      <dc:date>2021-08-12T07:23:26Z</dc:date>
    </item>
  </channel>
</rss>

