Hi I'm having trouble with the Create Point Text Element 1 code snippet:
https://github.com/Esri/arcgis-pro-sdk/wiki/ProSnippets-Layouts#create-point-text-element-1
on this line:
var ptTxtElm = ElementFactory.Instance.CreateTextGraphicElement( container, TextType.PointText, coord2D.ToMapPoint(), sym, textString, "New Point Text", true, elemInfo);
for 'container' variable I'm getting an error: The name 'container' does not exist in the current context. As I look at the snippet I don't see that container has been defined above this point
Thanks
Pete
Solved! Go to Solution.
when creating graphic elements, container can be one of:
a layout - eg var container = LayoutView.Active.Layout;
a graphicslayer - eg var container = MapView.Active.Map.GetLayersAsFlattenedList().OfType<GraphicsLayer>().First();
a group element. - eg var container = layout.GetElementsAsFlattenedList().OfType<GroupElement>().First();
when creating graphic elements, container can be one of:
a layout - eg var container = LayoutView.Active.Layout;
a graphicslayer - eg var container = MapView.Active.Map.GetLayersAsFlattenedList().OfType<GraphicsLayer>().First();
a group element. - eg var container = layout.GetElementsAsFlattenedList().OfType<GroupElement>().First();
thanks. using layout as container worked