Toolwindow docking & Stacking

Docking/MDI for WPF Forum

Posted 11 years ago by Mike Benson
Version: 4.5.0471
Avatar
Is there a way to keep the tool windows from stacking when they are programatically added?

if I call:
ToolWindow.Dock(this.docksite, Direction.Bottom)
for two different windows, it docks the first one and then `slides` the first one up and puts the second one under it. Is there a way to tell the second to dock alongside the first one?

Comments (7)

Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Do you mean dock them in the same container so they appear tabbed? If so, use Direction.Content as the second parameter.


Actipro Software Support

Posted 11 years ago by Mike Benson
Avatar
Quote:
...If so, use Direction.Content as the second parameter...


Here is the result:
{"Docking via Direction.Content into target 'ActiproSoftware.Windows.Controls.Docking.DockHost' is not supported."}
Basically, I create two toolwindows and then tell them to dock to the bottom edge.
tw.Dock(FFApp.MainPage.docksite, Direction.Bottom);
I need to make the first one dock to the bottom and then the second one should dock and turning both the second toolwindow and the first toolwindow into tabs in the docking area.


Here is my xaml

<DockPanel x:Name="DockPanel" themes:ThemeManager.Theme="Office2007Blue">
        <Grid Visibility="Hidden">
            <Grid.RowDefinitions>
                <RowDefinition Height="0"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="0"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Frame
            x:Name="NavigationFrame"
            Grid.Row="0"
            Grid.Column="0"
            Width="0"
            Height="0"
            Visibility="Hidden"/>
        </Grid>


        <shared:PixelSnapper DockPanel.Dock="Top">
            <ribbon:Ribbon x:Name="Desktop_RibbonStrip" IsQuickAccessToolBarCustomizationEnabled="True" IsCustomizeQuickAccessToolBarMenuItemVisible="True" ApplicationButtonImageSource="/Icons_Desktop/finfolio_32x32.png">
                <ribbon:Ribbon.ContextualTabGroups>
                    <ribbon:ContextualTabGroup Label="View" Name="View" />
                </ribbon:Ribbon.ContextualTabGroups>
                <ribbon:Ribbon.ApplicationMenu>
                    <ribbon:ApplicationMenu />
                </ribbon:Ribbon.ApplicationMenu>
                <ribbon:Ribbon.LayoutTransform>
                    <ScaleTransform ScaleX="{Binding ElementName=ribbonDemo, Path=RibbonScale}" ScaleY="{Binding ElementName=ribbonDemo, Path=RibbonScale}" />
                </ribbon:Ribbon.LayoutTransform>
                <ribbon:Ribbon.TabPanelItems>
                    <ribbon:Button KeyTipAccessText="Z" Command="ApplicationCommands.Help" Name="Help" Label="Help" />
                    <UIElement />
                </ribbon:Ribbon.TabPanelItems>
            </ribbon:Ribbon>
        </shared:PixelSnapper>

        <shared:PixelSnapper DockPanel.Dock="Bottom" >
            <StatusBar x:Name="StatusBar" Padding="0,2,0,0" Style="{DynamicResource {x:Static ribbon:RibbonStyles.StatusBarKey}}" >
                <StatusBarItem x:Name="StatusPanelText" Content="Ready" />
            </StatusBar>
        </shared:PixelSnapper>
        
        <shared:PixelSnapper DockPanel.Dock="Left">
            <navigation:NavigationBar 
                    x:Name="Desktop_SideNavigationBar"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch"
                    Margin="0,0,0,0" IsCustomizationEnabled="False" ContentWidth="150">


            </navigation:NavigationBar>
        </shared:PixelSnapper>
        

        
        <docking:DockSite Name="docksite">
            <!--
            <docking:DockSite.AutoHideLeftContainers>
                <docking:ToolWindowContainer Name="West_ToolWindowContainer">
                </docking:ToolWindowContainer>
                
                <docking:ToolWindowContainer Name="West_West_ToolWindowContainer">
                </docking:ToolWindowContainer>
            </docking:DockSite.AutoHideLeftContainers>

            <docking:DockSite.AutoHideRightContainers>
                <docking:ToolWindowContainer Name="East_ToolWindowContainer">
                </docking:ToolWindowContainer>
                <docking:ToolWindowContainer Name="East_East_ToolWindowContainer">
                </docking:ToolWindowContainer>
            </docking:DockSite.AutoHideRightContainers>
-->
            <docking:SplitContainer >
                <docking:SplitContainer Orientation="Vertical">
                    <docking:Workspace>
                        <docking:TabbedMdiHost IsCloseButtonOnTab="True" TabPlacement="Top" x:Name="TabbedMdiHost" >
                            <docking:TabbedMdiContainer x:Name="NavigationTab" >
                            </docking:TabbedMdiContainer>
                        </docking:TabbedMdiHost>
                    </docking:Workspace>
                </docking:SplitContainer>
            </docking:SplitContainer>
        </docking:DockSite>
    </DockPanel>
Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Oh, sorry I should have said the first parameter should target the first tool window you already docked.

So your code would be like:
tw.Dock(FFApp.MainPage.docksite, Direction.Bottom);
tw2.Dock(tw, Direction.Content);


Actipro Software Support

Posted 11 years ago by Mike Benson
Avatar
Doing this:

     ToolWindow tw = new ToolWindow(this.docksite, "Test1", "Test1", null, new TextBox());
     tw.Dock(this.docksite, Direction.Bottom);
            
     ToolWindow tw2 = new ToolWindow(this.docksite, "Test2", "Test2", null, new TextBox());
     tw2.Dock(this.docksite, Direction.Content);
results in the same error:
{"Docking via Direction.Content into target 'ActiproSoftware.Windows.Controls.Docking.DockHost' is not supported."}
Doing this:

    ToolWindow tw = new ToolWindow(this.docksite, "Test1", "Test1", null, new TextBox());
    tw.Dock(this.docksite, Direction.Bottom);
    
    ToolWindow tw2 = new ToolWindow(this.docksite, "Test2", "Test2", null, new TextBox());
    tw2.Dock(this.docksite, Direction.Bottom);
Stacks the panels.


It sort of makes sense, if I tell the second window to dock on the bottom then the first toolwindow is moved up. I need a dock direction like Direction.Bottom | Direction.Tab. Dock on the bottom, if there is something else there then go to tabbed mode.
Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Check what I last posted though, for the second tool window "tw2" I told it to dock "Content" against the first tool window ("tw"). This means it becomes tabbed with the first tool window that is already loaded in the layout.

In your code you were still targeting the DockSite when you passed the direction of Content, which is not allowed.

You can only dock "Content" (make tabbed) agains an existing tool window or tool window container in the layout.

Make sense?


Actipro Software Support

Posted 11 years ago by Mike Benson
Avatar
Missed that little detail, that makes it work. So for anyone else searching here is my sample resolution:

    ToolWindow tw = new ToolWindow(this.docksite, "Test1", "Test1", null, new TextBox());
    tw.Dock(this.docksite, Direction.Bottom);


    ToolWindow tw2 = new ToolWindow(this.docksite, "Test2", "Test2", null, new TextBox());

    Direction defaultDirection = Direction.Bottom;

    var t = (from toolWindow in docksite.ToolWindows
            where toolWindow != tw2 
                && toolWindow.GetDirectionRelativeToWorkspace() == defaultDirection
            select toolWindow).FirstOrDefault();

    if (t == null)
        tw2.Dock(this.docksite, defaultDirection);
    else
        tw2.Dock(t, Direction.Content);
As a wish list item, it would be helpful if we had an option to dock alongside other tabs so I would not have to go through the linq or loop to do this. Its not a big deal so this would fall low on the nice to have list.
Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Glad you got it working. Could you maybe provide a quick code sample showing ideally how you would do this with our object model assuming the requested option was implemented how you'd like?


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.