I would like to be able import a Layout from a PAGX file without actually adding it to the Project's set of ProjectItems. Is this possible?
Thus far, the only way I have found to import from PAGX programatically (and grab the recently added Layout) is to do something like this:
Item importedProjectItem = GetImportedLayoutProjectItem(workingDirectoryPath); await QueuedTask.Run(() => { List<LayoutProjectItem> layoutProjectItemsBeforeImport = Project.Current.GetItems<LayoutProjectItem>().ToList(); Project.Current.AddItem((IProjectItem)importedProjectItem); LayoutProjectItem importedLayoutProjectItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => !layoutProjectItemsBeforeImport.Contains(item)); } });
Of course, the call to Project.Current.AddItem() adds the Layout to the Project, which automatically brings up the Layout for editing in the GUI.
I have tried casting the Item in various places, and that never works - It seems that an actual LayoutProjectItem is not created - and thus the Layout object itself is not created - until the call to AddItem(). But is there a way to create a Layout object from a PAGX file without going through these steps?
don't save the project and it will not add the layout to the project.
My issue is that I don't want the Layout to become a part of the Project at all - I just want the in-memory Layout object.