Question

Initial layout and tools docking setup

Posted 6 months ago by Avatar Hagay

Hi,

Please see the bellow illustration.

I can't understand the way to accomplish that.

Thanks in advance!

 

Initial/Startup Layout:
 _______________________________________________________________________________________ 
|      |                                                  |                             |
|  T1  |                                                  |             T2              |
| (AH) |                                                  |           (Docked)          |
|      |                                                  |                             |
|      |                                                  |                             |
|      |                                                  |                             |
|      |                                                  |                             |
|      |                                                  |                             |
|      |                                                  |                             |
|      |                                                  |                             |
|______|__________________________________________________|_____________________________|
|  T3    |    T4    |   T5    |                                                         |
| (AH)   |   (AH)   |  (AH)   |                                                         |
|________|__________|_________|_________________________________________________________|


Desired Layout when user firstly docks any of T1/T3/T4/T5:
 _______________________________________________________________________________________ 
|      |                                                  |                             |
|  T1  |                                                  |             T2              |
| (AH) |                                                  |           (Docked)          |
|  or  |                                                  |                             |
|(Dock)|                                                  |                             |
|      |                                                  |                             |
|______|__________________________________________________|                             |
|                                                         |                             |
|                     T3/T4/T5                            |                             |
|                     (Docked)                            |                             |
|                                                         |                             |
|                                                         |                             |
|                                                         |                             |
|_________________________________________________________|_____________________________|
 

Comments (8)

Posted 6 months ago by Actipro Software Support - Cleveland, OH, USA

Hello,

If you have this initial XAML layout:

<docking:DockSite WindowDefaultLocationRequested="DockSite_WindowDefaultLocationRequested">
	<docking:DockSite.AutoHideLeftContainers>
		<docking:ToolWindowContainer>
			<docking:ToolWindow Title="T1" />
		</docking:ToolWindowContainer>
	</docking:DockSite.AutoHideLeftContainers>
			
	<docking:DockSite.AutoHideBottomContainers>
		<docking:ToolWindowContainer>
			<docking:ToolWindow Title="T3" />
			<docking:ToolWindow Title="T4" />
			<docking:ToolWindow Title="T5" />
		</docking:ToolWindowContainer>
	</docking:DockSite.AutoHideBottomContainers>
			
	<docking:SplitContainer Orientation="Horizontal">
		<docking:Workspace>
			<docking:TabbedMdiHost x:Name="tabbedMdiHost" />
		</docking:Workspace>
				
		<docking:ToolWindowContainer>
			<docking:ToolWindow Title="T2" />
		</docking:ToolWindowContainer>
	</docking:SplitContainer>
</docking:DockSite>

And you want T3-5 to end up below the MDI area, you can add logic like this:

private void DockSite_WindowDefaultLocationRequested(object sender, DockingWindowDefaultLocationEventArgs e) {
	if ((e.State == DockingWindowState.Docked) && (e.Target == null)) {
		switch (e.Window.Title) {
			case "T3":
			case "T4":
			case "T5":
				e.Target = tabbedMdiHost;
				e.Side = Side.Bottom;
				break;
		}
	}
}

Please see the "Docking / Docking Window Features / Lifecycle and Docking Management" topic for more information on that event.  There is a "Default Locations" section that describes it and a similarly named QuickStart in the samples that shows multiple usage scenarios.


Actipro Software Support
Posted 6 months ago by Hagay

Thanks fot the response.
However, this isn't exactly what I needed.

The result I get is:
 _______________________________________________________________________________________ 
|      |                                                  |                             |
|  T1  |                                                  |             T2              |
| (AH) |                                                  |           (Docked)          |
|  or  |                                                  |                             |
|(Dock)|                                                  |                             |
|      |                                                  |                             |
|      |__________________________________________________|                             |
|      |                                                  |                             |
|      |              T3/T4/T5                            |                             |
|      |              (Docked)                            |                             |
|      |                                                  |                             |
|      |                                                  |                             |
|      |                                                  |                             |
|______|__________________________________________________|_____________________________|
 
 While I need:
 _______________________________________________________________________________________ 
|      |                                                  |                             |
|  T1  |                                                  |             T2              |
| (AH) |                                                  |           (Docked)          |
|  or  |                                                  |                             |
|(Dock)|                                                  |                             |
|      |                                                  |                             |
|______|__________________________________________________|                             |
|                                                         |                             |
|                     T3/T4/T5                            |                             |
|                     (Docked)                            |                             |
|                                                         |                             |
|                                                         |                             |
|                                                         |                             |
|_________________________________________________________|_____________________________|
 
 

When I try to set the e.Target to be the SplitContainer containing T1 and the main MDI host, it won't let me as the SplitContainer isn't an IDockTarget.

 

Please see the "Docking / Docking Window Features / Lifecycle and Docking Management" topic

I actually read it several time. 
I thought that this kind of initial setup is more likely to be set in the markupcode (xaml).

Posted 6 months ago by Actipro Software Support - Cleveland, OH, USA

Hello,

That is true, SplitContainer isn't an IDockTarget so you can't dock against it.

But even if we allowed it, you wouldn't be able to achieve what you diagrammed above.  Because if you started off with a single horizontal SplitContainer of T1/workspace/T2, when you targeted that SplitContainer and docked below it, the T3/T4/T5 would span the entire bottom width of the dock host.

What you might be better off doing is making your XAML layout start off with everything Docked how you want it.  Then programmatically auto-hide the appropriate tool windows before the user interacts with them.  That will establish the more complex hierarchy you are looking for.  And the Docked-state breadcrumbs left behind when you auto-hide the tool windows will allow them to restore where you wanted later on.


Actipro Software Support
Posted 6 months ago by Hagay

Hi, thanks for the explanation.

If I'd go for the approach you suggest, what would be the right place/time to do that -

in the constructor of the "view" that contains the Dock-Site?

in the Loaded event handler of the Dock-Site?

in another event handler?

Posted 6 months ago by Hagay

Well, I did what you suggested...

The problem is that when the user ask to dock any of T3/4/5, the docking appears to happen in a separate "tray".

For example, this is how it looks if the user docks T3 and then T4 also (not touching T5) - 

 _______________________________________________________________________________________ 
|      |                                                  |                             |
|  T1  |                                                  |             T2              |
| (AH) |                                                  |           (Docked)          |
|  or  |                                                  |                             |
|(Dock)|                                                  |                             |
|      |                                                  |                             |
|______|__________________________________________________|                             |
|                                                         |                             |
|                     T3/T4                               |                             |
|                     (Docked)                            |                             |
|                                                         |                             |
|                                                         |                             |
|                                                         |                             |
|_________________________________________________________|                             |
|  T3  |  T4  |                                           |                             |
|______|______|___________________________________________|                             |
|  T5  |                                                  |                             |
|______|__________________________________________________|_____________________________|

 I want it all to still appear on the same "tray"...

Posted 6 months ago by Actipro Software Support - Cleveland, OH, USA

Hello,

That's odd, I'm not sure what you are doing to get that layout, but this works for me:

<docking:DockSite x:Name="dockSite" Grid.Row="1">
	<docking:SplitContainer Orientation="Horizontal">
		<docking:SplitContainer Orientation="Vertical">
			<docking:SplitContainer Orientation="Horizontal">
				<docking:ToolWindowContainer>
					<docking:ToolWindow x:Name="tool1" Title="Tool1" />
				</docking:ToolWindowContainer>
						
				<docking:Workspace x:Name="workspace">
					<docking:TabbedMdiHost x:Name="tabbedMdiHost" />
				</docking:Workspace>
			</docking:SplitContainer>
					
			<docking:ToolWindowContainer>
				<docking:ToolWindow x:Name="tool3" Title="Tool3" />
				<docking:ToolWindow Title="Tool4" />
				<docking:ToolWindow Title="Tool5" />
			</docking:ToolWindowContainer>
		</docking:SplitContainer>
				
		<docking:ToolWindowContainer>
			<docking:ToolWindow x:Name="toolWindow2" Title="Tool2" />
		</docking:ToolWindowContainer>
	</docking:SplitContainer>
</docking:DockSite>

With this code-behind:

private void Window_Loaded(object sender, RoutedEventArgs e) {
	if (!isInitialized) {
		isInitialized = true;
		((ToolWindowContainer)tool1.ParentContainer).AutoHide();
		((ToolWindowContainer)tool3.ParentContainer).AutoHide();
	}
}

Actipro Software Support
Posted 6 months ago by Hagay

That's exactly what I did.

Please try the following - 
   after the view is initially loaded, dock Tool3 and Tool4.
   you should see that the tabs representing Tool3 and Tool4 appear above the tab representing Tool5 (which is still hidden).

Posted 6 months ago by Actipro Software Support - Cleveland, OH, USA

Hello,

When I do the exact code I have in our previous post and then slide open Tool3 and click the auto-hide pin button in the title bar, it docks Tool3/Tool4/Tool5 all together (and not individually) exactly where you wanted them.  If you are seeing different, then perhaps you doing some different run-time actions or have some additional code somewhere triggering other behavior?


Actipro Software Support
Information The latest build of this product (2018.1 build 0671) was released 1 month ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.