Setting Docked window width

Docking/MDI for WPF Forum

Posted 9 years ago by David Sherwood
Avatar
I'm having difficulty figuring out how to set the width of a tool window using ControlSize. I would like to set the width of left and right docked windows. First, how do I find the left and right ToolWindowContainers?. Second, how do I only change the width and not the height?

Comments (6)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi David,

Determining which ToolWindowContainers are on the "left" or "right", really depends on how you are populating the DockSite. You could have several ToolWindowContainers that are located to the left of the Workspace, but are docked side-by-side. The ControlSize can only be set before the ToolWindowContainer is loaded, so you'd typically set this in you XAML or on the ToolWindowContainer after you create it in code-behind.

You can use the SplitContainer.ResizeSlots method to dynamically resize items during runtime. We have TODO items marked down to added better support for specifying sizing the windows.

If a ToolWindowContainer is docked to the left/right then you can specify the size as "<DesiredWidth>,200", and it will ignore the 200 until it's docked on the bottom/top. There isn't currently a way to set only the width or height, but you could get the current ControlSize, change just the width, then set the ControlSize.


Actipro Software Support

Posted 9 years ago by David Sherwood
Avatar
My problem is in associating a ToolWindow with a ToolWindowContainer. I have tried to created my own ToolWindowContainer and set its size, but when I Dock the ToolWindow, it creates its own ToolWindowContaner and does not use mine. How do you get a ToolWindow to use a specific ToolWindowContainer? You talk about the life cycle of a Window but not a Container. When does it get loaded?
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi David,

If you call ToolWindow.Dock then it would detach from your ToolWindowContainer and create a new one. Instead, you can call ToolWindowContainer.Dock to dock the TWC and any TWs in it.

If that doesn't help, please put together a small sample project that reproduces the issue and send it over to our support address. Once we have that we can narrow down the issue/fix. Be sure to remove and executable files from your archive.


Actipro Software Support

Posted 9 years ago by David Sherwood
Avatar
I added ToolWindowContainers in my XAML and then when a tool wanted to dock, I would add it to the appropriate TWC. This worked fine until I used AutoHide. Then anything I added to the TWC would disappear. So I got rid of the TWC in XAML and did everything in code.
When a tool wants to dock, I search the DockSite's ToolWindow collection for a tool that's already dock in the desired direction. If I find one, I add the new tool to that tool's container. If I don't find one I:
• create a new TWC;
• set its size;
• Add it to the DockSite's SplitContainer;
• If the tool is already in a container, I remove it and if that makes its container empty, I remove it from the SplitContainer;
• add the tool to the TWC
• Dock the TWC
This is now working.
An awful lot of code just to override the control's initial width setting!
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi David,

If you use the ToolWindow.Dock(IDockTarget target, Direction direction) method, you should be able to cut out alot of that code. You can pass the ToolWindowContainer as the target and use Direction.Content. This would dock the ToolWindow object in the ToolWindowContainer, and remove it from any previous parents (as well as clear out any empty ToolWindowContainer elements left).


Actipro Software Support

Posted 9 years ago by David Sherwood
Avatar
Thanks for the tip. But I found that this does not get rid of empty containers. For every container the I create, the control creates another one with a "Track" object in it. These containers don't go away either when they are empty. But I thought I should at least clean up the ones that I create.
The latest build of this product (v2018.1 build 0675) 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.