Parameters
- styleItem
- The style item to check whether its styling can be applied
//Run within QueuedTask context. //Get the Style project items in the project var styleProjectItems = Project.Current?.GetItems<StyleProjectItem>(); //Get the ArcGIS 2D Style Project Item var styleProjectItem = styleProjectItems.OfType<StyleProjectItem>().FirstOrDefault(s => s.Name == "ArcGIS 2D"); if (styleProjectItem == null) return; //Get the north arrow style item you need var pointStyleItem = styleProjectItem.SearchSymbols(StyleItemType.PointSymbol, "Circle 3").FirstOrDefault(); if (pointStyleItem == null) return; //Select a North arrow layout element var layoutPointElement = layout.GetSelectedElements().FirstOrDefault(); if (layoutPointElement != null && layoutPointElement is GraphicElement ge) { if (layoutPointElement.CanApplyStyle(pointStyleItem)) { //The magic happens here //for Graphic Elements such as Point, Lines, Polys, text, preserve size. ge.ApplyStyle(pointStyleItem, true); } }
Target Platforms: Windows 11, Windows 10