This tutorial demonstrates how to create add-ins that control add-in loading, which assists with multiple add-in deployments.
With the ArcGIS Pro SDK for .NET, you can extend ArcGIS Pro with your own unique tools and workflows. Using Microsoft Visual Studio and the Pro SDK, developers can build Pro add-ins and solution configurations that provide users with custom functionality specific to their organization or industry.
The ArcGIS Pro uses DAML to manage add-in loading. You might find it beneficial at times to separate your ArcGIS Pro SDK customizations into more than one add-in. For example, if you want to incrementally release add-in functionality across a set of enhancements, or are gradually enhancing the capabilities of an existing add-in.
In this tutorial, you will create two add-ins that work together with dependencies for their UI aspects, leveraging DAML capabilities.
Prerequisites
- Microsoft Visual Studio is required. See the ArcGIS Pro system requirements for latest version and compatibility.
- Install ArcGIS Pro version 3.3 or higher.
- Install the ArcGIS Pro SDK for .NET. See the Installation ProGuide for more information.
Steps
Create a new add-in solution with a simple button
-
Start Visual Studio.
-
Choose File > New > Project and then from the ArcGIS templates group, select ArcGIS Pro Module Add-in. Name the add-in project
Load
.First Addin By default, the
Config.daml
file opens in Visual Studio. TheModule1.cs
file contains add-in module code.Note also in the
Config.daml
file that theid
attribute of theinsert
tag matches the ID within theModule Module1.cs
file and theclass
attribute also matches the class name of the module.Name The ArcGIS templates group is located in Templates > Visual C# > ArcGIS. Confirm that the latest .NET Framework is selected.
Add a button control to your add-in
-
Right click the project and choose Add > New Item and then from the ArcGIS Pro Add-ins group select ArcGIS Pro Button from the list of item templates. When prompted, use the default name
Button1.cs
and click Add to close the dialog box. The Button template provides the contents of the class file, as well as corresponding code in theConfig.daml
file for the Pro UI.Add the following code to the
On
method of Button1:Click Use dark colors for code blocks Copy ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Add-in 1's Button here!", "Info");
-
Update the
Config.daml
file AddInInfo section so that the DAML appears as follows:In
Config.daml
, take note of the following three ID values:- AddInInfo id The GUID value unique to your add-in. For example, the value in quotes:
Add
.In Info id="{b1fb7998-a377-4440-bbfc-d1326735edd6}" - insertModule id This is based on the DAML above, and should be
"
.Load First Addin _Module" - group id This is the control group in which the button is contained, based on the DAML above. It should be
"
.Load First Addin _Group1"
Use dark colors for code blocks Copy </AddInInfo> <!-- ** ADD ** --> <modules> <insertModule id="LoadFirstAddin_Module" className="Module1" autoLoad="false" caption="Module1"> <tabs> <tab id="LoadFirstAddin_Tab1" caption="Loading Test"> <group refID="LoadFirstAddin_Group1"/> </tab> </tabs> <groups> <group id="LoadFirstAddin_Group1" caption="Add-in 1 Group" appearsOnAddInTab="false"> <button refID="LoadFirstAddin_Button1" size="large" /> </group> </groups> <controls> <button id="LoadFirstAddin_Button1" caption="Add-in 1 Button" className="Button1" loadOnClick="true" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue16.png" largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue32.png"> <tooltip heading="Tooltip Heading">Tooltip text<disabledText /></tooltip> </button> </controls> </insertModule> </modules>
- AddInInfo id The GUID value unique to your add-in. For example, the value in quotes:
Build and test Load First Addin
-
Build your project and debug any issues. Start the project, which launches ArcGIS Pro. Create a new project or open an existing project when the start page appears.
-
Click on the new Add-In tab called Loading Test and find your new button with the Add-in 1 Button caption. Press the button to make sure that the message box is working.
-
If everything works properly, you are now ready to build your second add-in which integrates with LoadFirstAddin and place a new button in the same control group with your first add-in.
-
Save your project and close Visual Studio.
-
Create a new add-in, Load Second Addin
-
Start Visual Studio.
-
Choose File > New > Project and then from the ArcGIS templates group, select ArcGIS Pro Module Add-in. Name the add-in project
Load
.Second Addin
Add a button control to your second add-in
-
Right click the project and choose Add > New Item and then from the ArcGIS Pro Add-ins group select ArcGIS Pro Button from the list of item templates.
-
When prompted, name the class
Button2.cs
and press Add to close the dialog box. The Button template provides the contents of the class file, as well as a corresponding code in theConfig.daml
file for the Pro UI.Add the following code to the
On
method of Button2:Click Use dark colors for code blocks Copy ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Add-in 2's Button here!", "Info");
-
Update the
Config.daml
file AddInInfo section so that the DAML appears as follows:-
In the LoadSecondAddin DAML code above, take note of the updates that were referenced when you updated the
Config.daml
for the earlier LoadFirstAddin. -
There is a new dependencies section included here. The dependency name references the GUID of LoadFirstAddin. This ensures that LoadFirstAddin is required to be loaded first.
-
There is a new updateModule section, which references the
insert
andModule id group id
from LoadFirstAddin.
Use dark colors for code blocks Copy </AddInInfo> <!-- ** ADD ** --> <modules> <insertModule id="LoadSecondAddin_Module" className="Module1" autoLoad="false" caption="Module1"> <controls> <!-- add your controls here --> <button id="LoadSecondAddin_Button2" caption="Add-in 2 Button" className="Button2" loadOnClick="true" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue16.png" largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue32.png"> <tooltip heading="Tooltip Heading">Tooltip text<disabledText/></tooltip> </button> </controls> </insertModule> <updateModule refID="LoadFirstAddin_Module"> <groups> <updateGroup refID="LoadFirstAddin_Group1"> <insertButton refID="LoadSecondAddin_Button2"/> </updateGroup> </groups> </updateModule> </modules>
-
Build and test Load Second Addin
-
Build your project and debug any issues. Start the project, which will launch ArcGIS Pro. Create a new project or open an existing project when the start page appears.
-
Click on the Add-In tab called Loading Test, which should be loaded from the earlier steps.
-
Confirm that your new LoadSecondAddin button with the Add-in 2 Button caption is loaded to the right of the Add-in 1 Button in the same Add-in 1 group.
-
Press the button to ensure that the message box functions as expected.
-
What's Next?
Learn how to use additional ArcGIS Pro SDK for .NET features in these tutorials: