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);
}
}
}
}
}
Did you try waiting for the ActivePaneInitializedEvent to fire?
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.
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.
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
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?
Hi Marvis,
States are different from Events - you cannot subscribe to them. They are useful for enabling/disabling controls.
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?