{
//Add the style to the current project
string stylePath = @"C:\MyStyles\OldStyle.stylx";
//Note: Needs QueuedTask to run
StyleHelper.AddStyle(Project.Current, stylePath);
StyleProjectItem styleToUpgrade = Project.Current.GetItems<StyleProjectItem>().First(x => x.Path == stylePath);
//returns true if style can be upgraded
bool canUpgrade = styleToUpgrade.CanUpgrade;
}
{
bool success = false;
//Add the style to the current project
string stylePath = @"C:\MyStyles\OldStyle.stylx";
//Note: Needs QueuedTask to run
StyleHelper.AddStyle(Project.Current, stylePath);
StyleProjectItem styleToUpgrade = Project.Current.GetItems<StyleProjectItem>().First(x => x.Path == stylePath);
//Verify that style can be upgraded
if (styleToUpgrade.CanUpgrade)
{
//Note: Needs QueuedTask to run
success = StyleHelper.UpgradeStyle(styleToUpgrade);
}
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)