ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / StyleHelper Class / UpgradeStyle Method
The StyleProjectItem to upgrade to the current ArcGIS Pro version.
Example

In This Topic
    UpgradeStyle Method
    In This Topic
    Upgrades the specified style to the current ArcGIS Pro version. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public static bool UpgradeStyle( 
       StyleProjectItem styleProjectItem
    )
    Public Shared Function UpgradeStyle( _
       ByVal styleProjectItem As StyleProjectItem _
    ) As Boolean

    Parameters

    styleProjectItem
    The StyleProjectItem to upgrade to the current ArcGIS Pro version.

    Return Value

    A boolean indicating if the upgrade operation succeeded.
    Exceptions
    ExceptionDescription
    Upgrading a style cannot be performed on a read-only style.
    Upgrading a style cannot be performed on a current or newer version.
    This method must be called within the lambda passed to QueuedTask.Run
    Remarks
    Potential reasons for failure are: style is invalid or read-only
    Example
    How to upgrade a style
    //Pass in the full path to the style file on disk
    public async Task<bool> UpgradeStyleAsync(string stylePath)
    {
      bool success = false;
    
      //Add the style to the current project
      await QueuedTask.Run(() => StyleHelper.AddStyle(Project.Current, stylePath));
      StyleProjectItem style = Project.Current.GetItems<StyleProjectItem>().First(x => x.Path == stylePath);
    
      //Verify that style can be upgraded
      if (style.CanUpgrade)
      {
        success = await QueuedTask.Run(() => StyleHelper.UpgradeStyle(style));
      }
      //return true if style was upgraded
      return success;
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also