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?
Solved! Go to Solution.
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
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
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.