Very Very Simple Problem (I guess)

Oct 30, 2008 at 10:59 AM
Just started with AvalonDock - great stuff.

Here's my problem: I have this very simple XAML:

<Window x:Class="AvalonDockStarter.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock"
    Title="Window1" Height="300" Width="300">

    <Grid>
        
        <ad:DockingManager x:Name="dockManager">
            
            <ad:ResizingPanel Orientation="Horizontal">

                <ad:DockablePane Name="MainPane">

                </ad:DockablePane>

            </ad:ResizingPanel>
            
        </ad:DockingManager>
        
    </Grid>
    
</Window>

I add stuff into the MainPane using the dockManager.DropInto(pane,MainPane) call where pane is an AvalonDock.DockablePane that I create in C# at runtime. All works great. Can keep dropping in panes no problem.

Now I want to add a Menu at the top of my app, underneath the blue title bar of the window. I want this to be always visible and have the docking manager not use the whole window but only the portion of it below the menu. So I try:

<Window x:Class="AvalonDockStarter.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock"
    Title="Window1" Height="300" Width="300">

    <Grid>
        
        <Menu>
            
            <MenuItem Header="File"></MenuItem>
            
        </Menu>

        
        <ad:DockingManager x:Name="dockManager">
            
            <ad:ResizingPanel Orientation="Horizontal">

                <ad:DockablePane Name="MainPane">

                </ad:DockablePane>

            </ad:ResizingPanel>
            
        </ad:DockingManager>
        
    </Grid>
    
</Window>

But dockManager is still using all of window so menu is hidden behind my docking content. I can drag my main dockablePane out of the way and see the menu sitting there underneath.

Can anyone help me please?

(Possibly related issues -
Lets say I dock some AvalonDock.DockablePane's - they all appear nicely tabbed, now I grab the main DockablePane (which they have all been dropped into) and if I try to dock this to the left or right I get a crash - but not top or bottom.

If I remove the RisizingPanel then my menu is no longer visible when I drag my DockablePane away! But the ablove crash no longer occurs)

Thanks for any help,
Mitch.


Oct 30, 2008 at 11:49 AM
Hi Mitch, use a DockPanel instead of a Grid:
Pseudo-code:
<DockPanel LastChildFill="true">

    <Menu DockPanel.Dock="Top"/>

    <ad:DockingManager>
        ....
    </ad:DockingManager>
</DockPanel>

An other thing: Are your sure you need a DockablePane? If you want to add documents at runtime use instead a DocumentPane.
I can suggest you to start develop with AvalonDock following this tutorial.

Ado
Oct 30, 2008 at 4:16 PM
Hi,

Thanks so much for your reply.

The DockPanel instead of the Grid solved all the menu problems - great.

You're right about that fact that I should be using a DocumentPane instead of a DockablePane. Do you mean I should have this instead:

<ad:DockingManager x:Name="dockManager">
            
            <ad:ResizingPanel Orientation="Horizontal">

                <ad:DocumentPane Name="MainPane">

                </ad:DocumentPane >

            </ad:ResizingPanel>
            
</ad:DockingManager>

If I do this, then my call to dockManager.DropInto(pane, MainPane) gives me a NullReferenceException. I call this method from the Window_Loaded event.

Thanks for any thoughts,
Mitch.