TOC disabled when Window opens

488
4
05-15-2018 12:46 PM
DevonCanady
New Contributor II

I have an ArcGIS Pro button add-in that opens a WPF window when clicked. If I wrap the OnClick handler code in QueuedTask.Run() the CIM works and I'm able to pan/zoom in the map view, but the TOC is still disabled.

I would like the user to be able to turn layers on/off and move the order around while the window is open. How might I enable this? When I use a dockpane this seems to be automatic but now I'm opening a (non-ArcGIS) WPF window.

internal class ShowExporterWindow : Button
{
    ExporterWindow window;

    protected override void OnClick()
    {
        QueuedTask.Run(() => {
            window = new ExporterWindow();
            window.ShowDialog();
        });
    }
}
Tags (2)
0 Kudos
4 Replies
UmaHarano
Esri Regular Contributor

Hi Devon

Messageboxes, windows ("Dialogs'), etc should be invoked on the UI thread, not within a QueuedTask.  Generally speaking, the only UI you should use in conjunction with a QueuedTask is a progressor. 

Thanks

Uma

internal class ShowExporterWindow : Button
{
    ExporterWindow window;
    window = new ExporterWindow();
    window.ShowDialog();  
}
0 Kudos
DevonCanady
New Contributor II

Uma,

Thanks for the reply, whenever I did this initially it froze up everything else in the UI for the project. I'm wondering how I can keep all the UI elements responsive while the window is open.

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Hi Devon,

 You are showing a Dialog (as the method says).  Dialogs are always 'modal' meaning these windows are subordinate to an application's main window which creates a mode where the main window can't be used.  So I suggest that you use a Dockpane for your workflow.  Check out our community samples (most have screen shots) to see something that is most fitting to your workflow.

- Wolf

0 Kudos
DevonCanady
New Contributor II

Ok I'll try using a Dockpane instead, thanks

0 Kudos