ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / Element Class / ApplyStyle(StyleItem) Method
The style item to apply
Example Version

ApplyStyle(StyleItem) Method
Apply the given style to the element. This method must be called on the MCT. Use QueuedTask.Run
Syntax
public virtual void ApplyStyle( 
   StyleItem styleItem
)

Parameters

styleItem
The style item to apply
Exceptions
ExceptionDescription
This method must be called within the lambda passed to QueuedTask.Run.
Incorrect style item for element
Remarks
Call CanApplyStyle to determine if the input style can be applied.
Example
Apply a style to a North Arrow
//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.FirstOrDefault(s => s.Name == "ArcGIS 2D");
if (styleProjectItem == null) return;
//Get the north arrow style item you need
var northArrowStyleItem = 
styleProjectItem.SearchSymbols(StyleItemType.NorthArrow, "ArcGIS North 18").FirstOrDefault();
if (northArrowStyleItem == null) return;
//Select a North arrow layout element
var northArrowElement = layout.GetSelectedElements().OfType<NorthArrow>().FirstOrDefault();
if (northArrowElement != null)
{
  //Check if the input style can be applied to the element
  if (northArrowElement.CanApplyStyle(northArrowStyleItem))
    //Apply the style
    northArrowElement.ApplyStyle(northArrowStyleItem);
}
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3.2 or higher.
See Also