

Public Class NorthArrowStyleItem Inherits StyleItem Implements System.ComponentModel.INotifyPropertyChanged
public class NorthArrowStyleItem : StyleItem, System.ComponentModel.INotifyPropertyChanged
{
//Create a north arrow using a style.
//Search for a style project item by name
StyleProjectItem arcgis2dStyles = Project.Current.GetItems<StyleProjectItem>()
.First(si => si.Name == "ArcGIS 2D");
//Construct on the worker thread
NorthArrowStyleItem naStyleItem = arcgis2dStyles.SearchNorthArrows(
"ArcGIS North 13").FirstOrDefault();
//Reference the map frame and define the location
MapFrame newFrame = layout.FindElement("New Map Frame") as MapFrame;
Coordinate2D nArrow = new Coordinate2D(6, 2.5);
//Construct the north arrow
var naInfo = new NorthArrowInfo()
{
MapFrameName = newFrame.Name,
NorthArrowStyleItem = naStyleItem
};
var newNorthArrow = ElementFactory.Instance.CreateMapSurroundElement(
layout, nArrow.ToMapPoint(), naInfo);
}
{
//Note: Must be on QueuedTask.Run
//Build geometry
Coordinate2D center = new Coordinate2D(7, 5.5);
//Reference a North Arrow in a style
StyleProjectItem stylePrjItm = Project.Current.GetItems<StyleProjectItem>()
.FirstOrDefault(item => item.Name == "ArcGIS 2D");
NorthArrowStyleItem naStyleItm = stylePrjItm.SearchNorthArrows(
"ArcGIS North 10")[0];
//Reference MF, create north arrow and add to layout
var mf = layout.FindElement("Map Frame") as MapFrame;
var narrow_info = new NorthArrowInfo()
{
MapFrameName = mf.Name,
NorthArrowStyleItem = naStyleItm
};
var arrowElm = (NorthArrow)ElementFactory.Instance.CreateMapSurroundElement(
layout, center.ToMapPoint(), narrow_info) as NorthArrow;
arrowElm.SetName("New North Arrow");
arrowElm.SetHeight(1.75);
arrowElm.SetX(7);
arrowElm.SetY(6);
}
{
//Search for north arrows
//Note: styleProjectItem was created above in the variable initialization section
//Note: Needs QueuedTask to run
styleProjectItem.SearchNorthArrows("searchString");
}
System.Object
ArcGIS.Desktop.Framework.Contracts.PropertyChangedBase
ArcGIS.Desktop.Mapping.StyleItem
ArcGIS.Desktop.Mapping.NorthArrowStyleItem
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)