ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / StyleProjectItem Class / CanUpgrade Property
Example

In This Topic
    CanUpgrade Property
    In This Topic
    Gets the value which indicates if the StyleProjectItem can be upgraded to the current ArcGIS Pro version.
    Syntax
    public bool CanUpgrade {get;}
    Public ReadOnly Property CanUpgrade As Boolean
    Example
    How to determine if a style can be upgraded
    //Pass in the full path to the style file on disk
    public async Task<bool> CanUpgradeStyleAsync(string stylePath)
    {
      //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);
    
      //returns true if style can be upgraded
      return style.CanUpgrade;
    }
    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