How to disable Add Data button in ArcGIS Pro application

326
2
Jump to solution
11-15-2021 03:36 AM
by Anonymous User
Not applicable

Hi,

We are currently dealing with multiple Map Frames, but only one Map Frame should have the Add Data option enabled, while for the others it should be disabled so that users cannot add data from external sources to the other Map Frames except one.

Below is the button I have to disable it for other Map Frames.

ShabinaBano_0-1636976046755.png

 

Is anyone aware of a way to accomplish this?

 

Thanks in advance!

0 Kudos
1 Solution

Accepted Solutions
KirkKuykendall1
Occasional Contributor III

Add a custom condition for "canaddlayers_condition", with a "canaddlayers_state".

Add a button wired to the canaddlayers_condition.  Delete Esri's addData button, and insert your own adddata button. Wire your button to use the Browse snippet when it's clicked.

KirkKuykendall1_0-1639421639627.png

Override the Initialize in your module to subscribe to active map view change event.

        protected override bool Initialize()
        {
            ActiveMapViewChangedEvent.Subscribe((ea) =>
            {
                string stateID = "canaddlayers_state";
                if (ea.IncomingView?.Map.Name == "Map1")
                    FrameworkApplication.State.Activate(stateID);
                else
                    FrameworkApplication.State.Deactivate(stateID);
                Trace.WriteLine("changed");
            });
            return base.Initialize();
        }

When I activate/deactivate Map1, the button gets activated/deactivated.

KirkKuykendall1_1-1639421986086.png

KirkKuykendall1_2-1639422009660.png

 

 

 

 

 

View solution in original post

2 Replies
KirkKuykendall1
Occasional Contributor III

Add a custom condition for "canaddlayers_condition", with a "canaddlayers_state".

Add a button wired to the canaddlayers_condition.  Delete Esri's addData button, and insert your own adddata button. Wire your button to use the Browse snippet when it's clicked.

KirkKuykendall1_0-1639421639627.png

Override the Initialize in your module to subscribe to active map view change event.

        protected override bool Initialize()
        {
            ActiveMapViewChangedEvent.Subscribe((ea) =>
            {
                string stateID = "canaddlayers_state";
                if (ea.IncomingView?.Map.Name == "Map1")
                    FrameworkApplication.State.Activate(stateID);
                else
                    FrameworkApplication.State.Deactivate(stateID);
                Trace.WriteLine("changed");
            });
            return base.Initialize();
        }

When I activate/deactivate Map1, the button gets activated/deactivated.

KirkKuykendall1_1-1639421986086.png

KirkKuykendall1_2-1639422009660.png

 

 

 

 

 

by Anonymous User
Not applicable

@KirkKuykendall1 

I Can't Thank You Enough. 

0 Kudos