Select to view content in your preferred language

Condition based on existence of layers in map

761
2
Jump to solution
03-01-2023 06:20 AM
TorbjørnDalløkken2
Occasional Contributor

Hi.

I've created an ArcGIS Pro Add-in which contains some buttons, that I'd like to enable/disable based on a condition. I've read about conditions and states in the ArcGIS Pro SDK Wiki, but I'm not quite sure on which event to subscribe to.

The add-in is dependent on the existence of three layers in the map and two tables (all in the same filegeodatabase).  I've already made a method that checks if the layers exists (when the buttons are clicked), but I'd like my buttons to be enabled if the layers exists in the map, and disabled if one or more of the layers are missing.

 How do I proceed with this? Which events should I be subscribing to?

 

0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi,

You need to listen these events: LayersAddedEvent, LayersRemovedEvent, StandaloneTablesAddedEvent and StandaloneTablesRemovedEvent. On each event you need to run your method for layers checking and set condition depending on results.

To set condition status use FrameworkApplication.State.Activate(stateID); or FrameworkApplication.State.Deactivate(stateID);

stateID is the string from your add-in daml file

View solution in original post

2 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

You need to listen these events: LayersAddedEvent, LayersRemovedEvent, StandaloneTablesAddedEvent and StandaloneTablesRemovedEvent. On each event you need to run your method for layers checking and set condition depending on results.

To set condition status use FrameworkApplication.State.Activate(stateID); or FrameworkApplication.State.Deactivate(stateID);

stateID is the string from your add-in daml file

FridjofSchmidt
Occasional Contributor

Probably I would also subscribe to the MapViewInitializedEvent, so you can analyze the layers and tables in the current map once the map view is ready.