Does anyone have a C# example of enabling word wrapping for legend labels? This setting is accessible on the Legend Arrangement Options in ArcMap but I can't find a way to set it in the API.
Hi Lesley,
There isn't a property for directly setting label wrapping on the legend object. But you can access the property via the CIM. Here's an example of how you do it.
await QueuedTask.Run(() => { var layout = LayoutView.Active.Layout; var legend = layout.FindElement("Legend") as Legend; if (legend == null) return; // get the CIM definition var def = legend.GetDefinition() as CIMLegend; // set label wrapping to 1 inch var labelWidthInches = 1; // CIM stores in points, so convert var labelWidthPoints = LinearUnit.Inches.ConvertTo(labelWidthInches, LinearUnit.Points); // assigning a non-zero value sets the wrapping def.LabelWidth = labelWidthPoints; // Zero value turns off description wrapping def.DescriptionWidth = 0; // update the CIM definition legend.SetDefinition(def); });
Thanks
Narelle
This works fine. It is quite obscure and I would never have found it on my own. It would be nice if this could be added as a property. Thanks for your help!
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.