<?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: Simple Labeling of a FeatureLayer in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/simple-labeling-of-a-featurelayer/m-p/1675198#M13338</link>
    <description>&lt;P&gt;Thank you Venkata,&lt;/P&gt;&lt;P&gt;This is much better than I thought it would be&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Dec 2025 20:21:33 GMT</pubDate>
    <dc:creator>EugeneStaten</dc:creator>
    <dc:date>2025-12-29T20:21:33Z</dc:date>
    <item>
      <title>Simple Labeling of a FeatureLayer</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/simple-labeling-of-a-featurelayer/m-p/1675084#M13335</link>
      <description>&lt;P&gt;Hi...&lt;/P&gt;&lt;P&gt;Though I've done a lot of Typescript programing for ArcGIS WebApplications, I am very now to ArcGIS Pro SDK for .net development.&lt;/P&gt;&lt;P&gt;We are porting an arcGIS Map 10.X addon to ArcGIS Pro 3.6.&amp;nbsp; A lot of things ave been quite straight forward, but I have run into a block, and hope for some help.&lt;/P&gt;&lt;P&gt;We have application configurations from System ENV, .json, .dat, and .ini files and have loaded all of it into a few Generic Dictionaries.&lt;/P&gt;&lt;P&gt;In on place within a file called LayerUtils, we load a list of FeatureLayers from a ThemeSet File and then send this list of layers to be added to the Map.&lt;/P&gt;&lt;P&gt;The method that adds the list of layers to the map calls SetLayerDisplayProperties(featureLayer) for preprocessing.&amp;nbsp; This method eventually sends the layer to&amp;nbsp;SetLayerLabel(featureLayer).&lt;/P&gt;&lt;P&gt;This is how the old code looks and I am trying to figure out why this small amount of code must be so ginormous (according to Google AI) when asked about labeling FeatureLayers.&lt;/P&gt;&lt;P&gt;I deduced the featureLayer.DisplayAnnotation = true, should be featureLayer.SetLabelVisibility(true).&lt;/P&gt;&lt;P&gt;I have the LabelSymbol defined in my version of SymbolUtils.&lt;/P&gt;&lt;P&gt;If someone can point me to or provide a succinct example of&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;P&gt;Yes.. It is old!!!&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; /// &amp;lt;summary&amp;gt;
 /// Sets the label for a layer
 /// &amp;lt;/summary&amp;gt;
 /// &amp;lt;param name="featureLayer"&amp;gt;An GeoFeatureLayer interface&amp;lt;/param&amp;gt;
 private static void SetLayerLabel(IGeoFeatureLayer featureLayer)
 {
     try
     {
         if (featureLayer != null)
         {
             int labelField = featureLayer.FeatureClass.Fields.FindField("Label");

             if (labelField &amp;gt; -1)
             {
                 featureLayer.DisplayAnnotation = true;
                 IAnnotateLayerProperties annotateLayerProps = null;
                 IElementCollection placedElements;
                 IElementCollection unplacedElements;
                 featureLayer.AnnotationProperties.QueryItem(0, out annotateLayerProps, out placedElements, out unplacedElements);
                 ILabelEngineLayerProperties labelEngineLayerProps = annotateLayerProps as ILabelEngineLayerProperties;
                 labelEngineLayerProps.Expression = "[Label]";
                 labelEngineLayerProps.Symbol = SymbolUtils.LabelSymbol;
             }
         }
     }
     catch (Exception ex)
     {
         ErrorHandling.ErrorMessage(ex);
     }
 }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It will be a while before I can test and debug this, but I just want to know If this is ideal, or if I should create an AnnotationLayer and do a who lot of stuff I don't want to do, if it isn't necessary.&lt;/P&gt;&lt;P&gt;This is what I came up with:&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; private void SetLayerLabel(FeatureLayer featureLayer)
 {
     //This is a continuation from the calling method and is already running inside of QueuedTask.Run()
     try
     {
         if (featureLayer != null)
         {
             int labelField = featureLayer.GetFeatureClass().GetDefinition().FindField("Label");
             if (labelField &amp;gt; -1)
             {
                 CIMFeatureLayer cimFeatureLayer = featureLayer.GetDefinition() as CIMFeatureLayer;
                 if (cimFeatureLayer != null)
                 {
                     CIMLabelClass newLabelClass = new CIMLabelClass()
                     {
                         Name = featureLayer.Name,
                         Visibility = true,
                         Expression = $"return {SymbolUtils.LabelSymbolTextFormat}",
                         TextSymbol = new CIMSymbolReference
                         {
                             Symbol = SymbolUtils.LabelSymbol
                         },
                         MaplexLabelPlacementProperties = new CIMMaplexLabelPlacementProperties
                         {
                             PreferHorizontalPlacement = true
                         }
                     };

                     List&amp;lt;CIMLabelClass&amp;gt; labelClasses = cimFeatureLayer.LabelClasses.ToList();
                     labelClasses.Add(newLabelClass);
                     cimFeatureLayer.LabelClasses = labelClasses.ToArray();
                     cimFeatureLayer.LabelVisibility = true;
                     featureLayer.SetDefinition(cimFeatureLayer);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ErrorHandling.ErrorMessage(ex);
     }
 }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any input!!!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Dec 2025 08:47:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/simple-labeling-of-a-featurelayer/m-p/1675084#M13335</guid>
      <dc:creator>EugeneStaten</dc:creator>
      <dc:date>2025-12-29T08:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Labeling of a FeatureLayer</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/simple-labeling-of-a-featurelayer/m-p/1675154#M13336</link>
      <description>&lt;P&gt;You’re on the right track, and no—you don’t need an AnnotationLayer unless you need stored, editable annotation. For simple dynamic labeling, stick with CIM label classes on the FeatureLayer.&lt;/P&gt;&lt;P&gt;A few key corrections:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;Expression&lt;BR /&gt;In Pro SDK, CIMLabelClass.Expression expects an Arcade label expression (string). For your case it can be as simple as:&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;"return $feature.Label"&lt;BR /&gt;or&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;"$feature.Label" depending on Arcade profile support, but safest is the return form.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;Don’t “add” label classes repeatedly&lt;BR /&gt;If you run this multiple times, you’ll keep appending classes. Better: replace the existing label class (or clear first).&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Enable labeling&lt;BR /&gt;Setting both cimFeatureLayer.LabelVisibility = true and the label class Visibility=true is correct.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Minimal pattern (inside QueuedTask.Run):&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var cim = (CIMFeatureLayer)featureLayer.GetDefinition();

cim.LabelClasses = new[]
{
  new CIMLabelClass
  {
    Name = "Default",
    Visibility = true,
    Expression = "return $feature.Label",
    TextSymbol = new CIMSymbolReference { Symbol = SymbolUtils.LabelSymbol },
    MaplexLabelPlacementProperties = new CIMMaplexLabelPlacementProperties()
  }
};

cim.LabelVisibility = true;
featureLayer.SetDefinition(cim);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bottom line: your approach is ideal for Pro 3.x. Only go AnnotationFeatureClass/AnnotationLayer if you need cartographic editing, conflict resolution stored in the DB, or performance for massive static maps.&lt;/P&gt;&lt;P&gt;– Venkat&lt;/P&gt;</description>
      <pubDate>Mon, 29 Dec 2025 17:30:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/simple-labeling-of-a-featurelayer/m-p/1675154#M13336</guid>
      <dc:creator>VenkataKondepati</dc:creator>
      <dc:date>2025-12-29T17:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Labeling of a FeatureLayer</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/simple-labeling-of-a-featurelayer/m-p/1675198#M13338</link>
      <description>&lt;P&gt;Thank you Venkata,&lt;/P&gt;&lt;P&gt;This is much better than I thought it would be&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Dec 2025 20:21:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/simple-labeling-of-a-featurelayer/m-p/1675198#M13338</guid>
      <dc:creator>EugeneStaten</dc:creator>
      <dc:date>2025-12-29T20:21:33Z</dc:date>
    </item>
  </channel>
</rss>

