How to open project file (.aprx) in new Map Tab with code Arcgis Pro SDK

01-04-2018 02:10 AM
Occasional Contributor II


-We have current project file (Test.aprx) for example @"C:\temp\Test.aprx" .

-We are use code like below but It can not open in new map tab , It open in same tab .How can we open .aprx file in new Tab ? 



Best Regards .

0 Kudos
3 Replies
Esri Regular Contributor

Hi Taner

The line of code in your example will open the project in the exact same state it was saved as previously. 

Are you trying to open an aprx project file, and then open a specific MapProjectItem in the project in a new pane?

If so, after you open the project you can use this code snippet to open a specific map in a new pane:

await QueuedTask.Run(() => {
    MapProjectItem mapProjItem = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(item => item.Name.Equals("EuropeMap"));



Occasional Contributor III

The key is that when you create your code is that many of your commands are asyn. This means they need to be in a async method and the method has to be public to avoid CalledOnWrongThreadException. For example, you could have a call in your 'regular' synchronous code to LoadTemplateProject, that then calls your async method.

public static void LoadTemplateProject(string myTemplatePath)

//Load the requested map template
var projectFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).ToString() + @"\ArcGIS\Projects";
CreateProjectSettings ps = new CreateProjectSettings()
CreateNewProjectFolder = true,
LocationPath = projectFolder,
TemplatePath = myTemplatePath,
TemplateType = TemplateType.LocalScene



public static async void LoadNewProject(CreateProjectSettings ps2)
//load the newly defined project; must be public to avoid threading errors!
   Project thePrj = await Project.CreateAsync(ps2);
   await Project.OpenAsync(thePrj.URI.ToString());
catch (Exception eX)


0 Kudos
by Anonymous User
Not applicable

Hi taner koka‌,

If you want to open the map from another project, or to reuse the map from your aprx file, it could be easier if you export as map file and load each map.

Below is the step you can do.

1. Open the aprx in which you have map to reuse,

2. right click the map and save as map file

3. Use this code to open the map file from other project go through with your addin

public void AddMapxfile(string mapxPath)
            var ps = new ProgressorSource("Processing.....");
//Remember this is async, be sure to have await and change this method to async if you have another statement depend on that statement to finish
            QueuedTask.Run(() =>
                    IProjectItem mapX = ItemFactory.Instance.Create(mapxPath) as IProjectItem;
                catch (Exception exc)
                    //handle the exception
            }, ps.Progressor);

0 Kudos