This project is read-only.

[Version 1.3.3571.0, .NET 4] Loaded/Unloaded event

Jul 13, 2010 at 2:09 PM
First: I really like this library. ;-) But: I do a lot of code in the Loaded and Unloaded event of my windows. But it seems that these events are also triggered whenever I manually switch documents or create a new document group. So: Is there anyway for me to do better? Like are there events when a panel has been created and closed? Thanks for your help!
Jul 13, 2010 at 2:36 PM
Thanks, dockable contents are loaded/unloaded as user move them. This happens because AvalonDock phisically add/remove them to or from containers (Panes) causing WPF to load/unload them as controls are added or removed from parent children collections. Ado
Jul 14, 2010 at 10:28 AM
Thanks for fast answer. So now I understand that Loaded/Unloaded is not a good idea. So I am now using Initilized event which is fired only onc.e But how I can intercept a Close() on the DockableContent? I need to do some resource releasing there. Thanks for your help.
Jul 14, 2010 at 10:44 AM

By default DockableContents are hidden when user click the X button. To allow user to close the content you should set its property IsCloseable to true.

After that just override OnClonsing/OnClose methods to unitialize your stuff.


Jul 15, 2010 at 7:28 PM
Edited Jul 15, 2010 at 8:02 PM

If DockableContents are hidden by default when the user clicks the X button, how can you programmatically bring it back? The Show method doesn't appear to do anything, and while there is a Hide method, there isn't some sort of Unhide method. Also, Hide doesn't appear to do anything anyway.

Edit: Here's my XAML.

       <aDock:DockingManager x:Name="dockManager" Grid.Row="2" IsAnimationEnabled="True">
            <aDock:ResizingPanel  Orientation="Vertical" >
                <aDock:ResizingPanel x:Name="resizeScenarioPanel"  Orientation="Horizontal" >                
                    <aDock:DocumentPane x:Name="scenarioDocumentPane">
                <aDock:DockablePane x:Name="messagesDockPane" aDock:ResizingPanel.ResizeHeight="150" >

                    <aDock:DockableContent x:Name="messagesPane" aDock:ResizingPanel.ResizeHeight="150" Title="Messages" >
                        <TextBox  Name="txtMessages" IsReadOnly="True" VerticalScrollBarVisibility="Auto" />
I want to be able to make messagesPane reappear if the user closes it, and am not sure how to do it.

Jul 17, 2010 at 1:03 PM

The Show method of DockableContent object should bring back the content where it was previously hidden. If this doesn't happen the it's a bug to fix. Could you please describe steps to reproduce the problem?


Jul 19, 2010 at 12:53 PM

The XAML I use is in my post above. I have a WPF menuitem click event as follows:

private void menuShowMessage_Click(object sender, RoutedEventArgs e)


When the user closes the DockableContent object by clicking the X button, they should be able to click the menuitem to bring back it back. However, this does not occur.

Jul 19, 2010 at 1:34 PM
Edited Jul 19, 2010 at 1:35 PM

Sorry but I can't repro the issue. Using above XAML code with the event handler that calls the Show method of the DockableContent it worked as aspected.

If you want you can post a sample project that shows the problem so I can find it,


PS: I'm assuming you're using version 1.3.3571.0 or later.

Jul 19, 2010 at 2:13 PM
Hmm, strange. I will try to work up a sample project. I am using version 1.3.3579 with .NET 4, and this also occurred with version 1.3.3571. I will post again when I have a sample project. Thanks again for your help.
Jul 19, 2010 at 7:45 PM
Well it appears I'm just an idiot and don't know how to assign my event handlers properly. Everything's working properly, my mistake! :)
Aug 13, 2013 at 10:03 PM
I have same problem, but i also notice that the UserControl.Load is called on all load document when i add another Item?

for example i have load a ucercontrol as document in avalondock, then i load another the first one that was loaded it calls it's loaded even first, then the 2nd is called afterwards how do i get around that?
Aug 14, 2013 at 2:44 AM
Is there any way to disable loading, and unloading of dockable contents.