Using Application Startup Event in Add-in

1032
3
02-13-2019 05:44 AM
AlexanderFischer
New Contributor III

I am developing an ArcGIS Pro Add-In (not ArcGIS Pro Configuration). In my Add-in project, is there any way to get notified and execute some code when the user opens up the ArcGIS Pro application? I know that there is a class called ApplicationStartupEvent, but in order to use this class I need to subscribe to it first without having the user click on something in the ribbon. Is this possible? Or is it true that using ArcGIS Pro Configuration is the only way to achieve this?

0 Kudos
3 Replies
by Anonymous User
Not applicable

Zeno,

In an add-in i would usually hook into the project opened event.

You can do this in your add-in module class by overriding the initialize call.

    protected override bool Initialize()
    {
      //listen to project open/close events
      ProjectOpenedEvent.Subscribe(onProjectOpened);
      ProjectClosedEvent.Subscribe(onProjectClosed);

      return true;
    }
0 Kudos
UmaHarano
Esri Regular Contributor

Zeno,

In your add-in's config.daml, modify the autoLoad attribute to be true. This will allow your add-in to load automatically instead of waiting for a click on the ribbon.  This attribute is located in the insertModule element.

<AddInInfo>
....
</AddInInfo>
  <modules>
 <insertModule autoLoad="true" caption="Module1">‍
....‍‍‍‍‍‍
</insertModule>‍‍‍‍‍‍‍‍‍‍‍‍‍‍
AlexanderFischer
New Contributor III

Thank you, that's exactly what I was looking for.

0 Kudos