ActivePaneChangedEvent unexpected behaviour

1876
7
03-29-2021 02:38 PM
MarvisKisakye1
Occasional Contributor

I am writing code that opens up the attribute table and then proceeds to open the GoTo command. The attribute table needs to be fully loaded before the GoTo command will execute. I subscribed to the ActivePaneChangedEvent to ensure initialisation of the table. I was surprised however to discover that the ActivePaneChangedEvent happens before the pane is fully initialised. In the code below pane.Initialized returns false inside the ActivePaneChangedEvent. Is this expected behaviour? @UmaHarano @Wolf 

 

 

ActivePaneInitializedEvent.Subscribe(OnActivePaneInitialized);
                var openTableBtnCmd = FrameworkApplication.GetPlugInWrapper("esri_editing_table_openTablePaneButton") as ICommand;
                if (openTableBtnCmd != null)
                {
                    // Let ArcGIS Pro do the work for us
                    if (openTableBtnCmd.CanExecute(null))
                    {
                        openTableBtnCmd.Execute(null);
                    }
                }
private void OnActivePaneInitialized(ActivePaneInitializedEventArgs obj)
        {
            var pane = FrameworkApplication.Panes.ActivePane;
            if (pane is ITablePane)
            {
                if (pane.Initialized)
                {
                    var goToBtnCmd = FrameworkApplication.GetPlugInWrapper("esri_editing_tableGoTo") as ICommand;
                    if (goToBtnCmd != null)
                    {
                        if (goToBtnCmd.CanExecute(null))
                        {
                            goToBtnCmd.Execute(null);
                        }
                    }
                }
            }
        }

 

 

Tags (2)
0 Kudos
7 Replies
KirkKuykendall1
Occasional Contributor III

Did you try waiting for the ActivePaneInitializedEvent to fire?

0 Kudos
MarvisKisakye1
Occasional Contributor

Well, I subscribed to the ActivePaneInitializedEvent  and placed a breakpoint inside the OnActivePaneInitialized method. When execution got inside that method, I expected pane.Initialized to be true but it was false. So yes ActivePaneInitializedEvent  did fire first.

0 Kudos
KirkKuykendall1
Occasional Contributor III

Hmm, sounds like a bug to me. When an ActivePaneInitializedEvent fires, I would expect  FrameworkApplication.Panes.ActivePane.Initialized to be true, but it's not for me either with 2.7.1

As a workaround, I was going to suggest subscribing to INotifyPropertyChanged when ActivePaneInitialized fires, and then wait for the PropertyChangedEvent to fire for the Initialized property - but that never fires either. Maybe another bug.

 

UmaHarano
Esri Regular Contributor

 Hi @MarvisKisakye1 

You can find out when the Attribute table pane Initialization has begun using the ActivePaneInitializedEvent.  But this doesn't tell you when the Pane is completely in a "ready" state.

Pro uses "states" to determine when something is ready - For example, the "esri_editing_tableOpenState" state tells the application  when the table is open and ready. This is when the "esri_editing_tableGoTo" button on the ribbon gets enabled.

Thanks

Uma

0 Kudos
MarvisKisakye1
Occasional Contributor

Is it possible to subscribe to the "esri_editing_tableOpenState" state? How can I listen for when the table is open and ready in order to programmatically open the  "esri_editing_tableGoTo" button?

0 Kudos
UmaHarano
Esri Regular Contributor

Hi Marvis,

States are different from Events - you cannot subscribe to them.  They are useful for enabling/disabling controls.

 

0 Kudos
MarvisKisakye1
Occasional Contributor

So what would you say would be the best way to accomplish what I am trying to do; open an attribute table, wait for it to be ready and then open the GoTo command?

0 Kudos