ArcGIS Pro 3.8 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
    {
      //Add the style to the current project
      string stylePath = @"C:\MyStyles\OldStyle.stylx";
      var project = Project.Current;
      await QueuedTask.Run(() => StyleHelper.AddStyle(project, stylePath));
      StyleProjectItem styleToUpgrade = Project.Current.GetItems<StyleProjectItem>().First(x => x.Path == stylePath);
    
      //returns true if style can be upgraded
      bool canUpgrade = styleToUpgrade.CanUpgrade;
    }
    How to upgrade a style
    {
      bool success = false;
      //Add the style to the current project
      string stylePath = @"C:\MyStyles\OldStyle.stylx";
      var project = Project.Current;
      await QueuedTask.Run(() => StyleHelper.AddStyle(project, stylePath));
      StyleProjectItem styleToUpgrade = Project.Current.GetItems<StyleProjectItem>().First(x => x.Path == stylePath);
    
      //Verify that style can be upgraded
      if (styleToUpgrade.CanUpgrade)
      {
        success = await QueuedTask.Run(() => StyleHelper.UpgradeStyle(styleToUpgrade));
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also