Initially hiding docking windows to improve performance

Docking/MDI for WPF Forum

Posted 14 years ago by Robert A. McCarter
Avatar
My main application window has a number of docking ToolWindows. Several of these tool windows seem to take quite a while to initialize (they have background graphics and complex controls). This really slows down the application's start-up time; when the main window calls InitializeComponent() it takes about 5 seconds to complete!

Additionally, once the main window has finished this initialization I actually call Close() on a number of the ToolWindow instances because they are only used later in the application (once the user has opened a document for example, at which point I call the tool window's Open() method).

Thus, it is very frustrating that these tool windows are taking so long to initialize. Additionally, these tool windows are visible for a very brief second before my code can close them (which looks quite bad).

Ideally, in the XAML I could indicate that the initial state of the tool windows is closed, so that they do not need to be initialized and do not appear initially. Unfortunately, looking at the ToolWindow API this doesn't seem possible.

The only other alternative I can come up with is to put the tool window XAML as a resource, and then in code when I want to display the window create the resource and try and add it to the correct docking location (this seems very tricky... how can I easily add something to the right or to the bottom?). This is unfortunate (not just becuase I have to code the solution myself, but also) because it makes it much harder to leverage the built-in docking layout persistence features of your product.

Actipro team - please help! I'm definitely open to suggestions.

Thank you very much,

Robert

[Modified at 09/07/2010 09:29 PM]

Comments (5)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Robert,

Our Docking & MDI Features demo shows how you can create a ToolWindow initially closed (search for "initiallyClosedToolWindow"), as well as initially auto-hidden (search for "toolboxToolWindow").

Alternatively, you can create/open the ToolWindows programmatically (again our demos show this), but it still has to be on the main UI thread (due to WPF restrictions). You can dock ToolWindows "relative" to the DockSite (i.e. left, right, etc) among other elements (i.e. other ToolWindows).


Actipro Software Support

Posted 14 years ago by Robert A. McCarter
Avatar
Wonderful, thank you very much!
Posted 14 years ago by Robert A. McCarter
Avatar
I ended up putting the expensive tool-window creation into the code-behind.

This helped start-up performance, but getting the tool windows into their correct location later on was non-trivial. I finally got this almost working, but I cannot for the life of me get the width of the right-hand tool-window to be anything but too small.

I found this in the documentation:

Sometimes you may wish to set a different default initial size for docking windows. This can be done via code by using the DockSite.SetControlSize method on the window container (like a ToolWindowContainer).

But this seemed to make no difference. Nor did setting the min-width on the tool-window or the tool-window's content.

Robert
Posted 14 years ago by Robert A. McCarter
Avatar
Additionally, when I change document tabs I don't seem to get a document-changed event anymore until I click into the document itself.
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Robert,

Can you please put together a small sample project the reproduces the issue and email it over to our support address? Be sure to remove any executables from the zip archive or rename the extension.

Keep in mind that if the DocumentWindow isn't properly created and registered with the DockSite, then it may not fire events correctly. You need to ensure you are using the constructor that takes a DockSite parameter.

Also if you are using WinForms Interop controls, then WPF doesn't always track focus properly. Unfortunately, in this case there isn't much we can do.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.