Hide an empty anchorable pane on app startup

Aug 2, 2012 at 8:56 PM
Edited Aug 2, 2012 at 8:56 PM

I have a setup that looks like this:

<avalonDock:LayoutPanel Orientation="Horizontal">
   <avalonDock:LayoutPanel x:Name="MainDocumentGroup" Orientation="Vertical">
         <avalonDock:LayoutDocumentPane />
         <avalonDock:LayoutAnchorablePane Name="RequiredResponsePane"
                                          DockHeight="400" />
   </avalonDock:LayoutPanel>
   <avalonDock:LayoutAnchorablePane Name="ToolsPane"
                                    DockWidth="100" />
 </avalonDock:LayoutPanel>

It all works really well except that when I startup I need the AnchorablePanes to not be taking up space.

They are empty until I add something to them.  Once I do, I will make them show up.  While using the application, I can add to the pane then close it to make it look like I want, but I need it to look like that at startup. 

Is that possible?

Aug 2, 2012 at 9:38 PM

If the pane has nothing in it you can close it in the code behind like this:

MyPaneName.ComputeVisibility();

That will check to see if there is any visible items in the pane, and if none will set it to hidden.

Aug 3, 2012 at 8:44 AM

I'm not sure why you are creating empty anchorable panes, but you ca call the DockingManager.Layout.CollectGarbage() to remove them at runtime. Could it be useful in your case?

Ado

Aug 3, 2012 at 2:05 PM

Thanks Ado,

Maybe I am doing it wrong.  I setup my AnchorablePanes in my Xaml, then I fill them when the user requests a "tool" (like Solution Exporer).

Maybe I should create the panes on the fly when the first user requests a tool that should go in them?

Either way, thanks for the answer.

Aug 3, 2012 at 2:18 PM

Yes, I think so, you should create the anchorable pane on the fly or better let AD to do it for you (consider that if the tool has been hidden before, AvalonDock tries to recover its previous position and size).

Ado

Aug 3, 2012 at 2:21 PM

My only problem with letting AD do it for me, is that it does not know the default location.  (Some should go on the bottom and some at the side.) 

But when it comes to showing it again, I see your point about letting AD put it where it was.  That will allow the user to not have to re-position every time they open the tool.

Thanks for the advice!