my control's Loaded event called multiple times

Docking/MDI for WPF Forum

Posted 13 years ago by Adam Petaccia
Version: 10.2.0533
I have controls which are required to do expensive setup once their properties are realized (IE: After IsInitialized). My controls do this on the Loaded event, due to the fact that they will only typically have to do this setup once. The problem is, IsLoaded fires more than once when elements are in MDI.

Loaded is spammed when the window is created, focused, or sometimes even when the window has been requested to close (as it must be focused first) and this is causing horrible performance degradation.

What needs to be done to avoid this behavior, or work around it?

Comments (1)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Adam,

Unfortunately we don't really have control over when Loaded fires or doesn't fire. It could do so in response to visibility changes, etc., but all that logic is in the core WPF framework.

One thing you could do as a workaround is store your own "isLoaded" variable and mark it true the first time Loaded is called. Then skip your Loaded code if that variable is true.

If you'd like us to look at it to see if there's anything more we can do on our end, please put together a new simple sample project that shows the issue, and email that to us. In the ZIP, don't include any .exe files and rename the .zip file extension.

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.