SplitContainer Widths

Docking/MDI for WPF Forum

Posted 15 years ago by United Biosource - United Biosource
Version: 4.5.0486
Avatar
I have the standard SplitContainer (copied from your sample code) with the main Workspace on the left and the ToolWindowContainer on the right (for the Properties grid). No matter how big the container, the right always defaults to a size that is too small. Setting MinWidth does not seem to matter. How can I set the size of the two sections of the SplitContainer?

Here is my xaml:

<docking:SplitContainer>
    <docking:Workspace Name="MainWorkspace">
        <docking:TabbedMdiHost >
            <docking:TabbedMdiContainer Name="MdiContainer" Loaded="MdiContainer_Loaded"  SelectionChanged="MdiContainer_SelectionChanged">
                    <docking:ToolWindow Name="SomeTool" Title="Some Tool" CanClose="false" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"></docking:ToolWindow>
            </docking:TabbedMdiContainer>
        </docking:TabbedMdiHost>
    </docking:Workspace>
    <docking:ToolWindowContainer MinWidth="275" HorizontalAlignment="Stretch">
            <docking:ToolWindow Title="Properties">                        
                <propgrid:PropertyGrid 
                    HorizontalAlignment="Stretch" 
                    Margin="0,0,0,0" 
                    Name="PropertiesGrid" 
                    VerticalAlignment="Stretch"
                    >
                </propgrid:PropertyGrid>
            </docking:ToolWindow>
            <docking:ToolWindow Title="Tool Window 2" />
    </docking:ToolWindowContainer>
</docking:SplitContainer>

Comments (7)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Don't use MinWidth, etc on containers. That will mess up how things work.

Instead check out this documentation topic, since it explains what you would want to do:
"Docking & MDI Docking Window Features / Lifecycle and Docking Management / Setting Docking Window Initial Sizes"


Actipro Software Support

Posted 15 years ago by United Biosource - United Biosource
Avatar
Thanks, but this isn't having any effect. I tried:

<docking:ToolWindowContainer HorizontalAlignment="Stretch" docking:DockSite.ControlSize="500,800">
and
DockSite.SetControlSize(PropertyToolWindow, new Size(500, 800));
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
We have some tweaks in layout that may help which will appear in the next maintenance release (hopefully tomorrow or Monday).

But another thing you could try in the meantime is setting ControlSize on the parent SplitContainer and the Workspace too. Like if you set the width on the SplitContainer ControlSize to be 800 (it will scale if the container doesn't end up being 800 at run-time), then make your Workspace ControlSize's width be 300 and your ToolWindowContainer ControlSize's width to be 500.


Actipro Software Support

Posted 15 years ago by United Biosource - United Biosource
Avatar
Assuming this is what you had in mind, it still doesn't work - looking forward to the next release:

            DockSite.SetControlSize(WsContainer, new Size(1200, 800));
            DockSite.SetControlSize(MainWorkspace, new Size(600, 800));
            DockSite.SetControlSize(PropertyToolWindow, new Size(600, 800));
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Sydney,

For the sake of testing I converted your XAML to this and tried it with the latest code here (for the next maint release) and it worked great:
<docking:DockSite x:Name="dockSite" UseHostedAutoHidePopups="False">
    <docking:SplitContainer>
        <docking:Workspace Name="MainWorkspace">
            <docking:TabbedMdiHost >
                <docking:TabbedMdiContainer Name="MdiContainer">
                    <docking:ToolWindow Name="SomeTool" Title="Some Tool" CanClose="false" />
                </docking:TabbedMdiContainer>
            </docking:TabbedMdiHost>
        </docking:Workspace>
        <docking:ToolWindowContainer docking:DockSite.ControlSize="500,500">
                <docking:ToolWindow Title="Properties" />                        
                <docking:ToolWindow Title="Tool Window 2" />
        </docking:ToolWindowContainer>
    </docking:SplitContainer>
</docking:DockSite>
The tool window container was 500 pixels. So hang in there a couple days until the release.

Also, I saw you were attaching to events on a TabbedMdiContainer instance. That is never a good idea since containers are transient. They are created and destroyed at runtime as needed. Use events on DockSite instead.


Actipro Software Support

Posted 15 years ago by United Biosource - United Biosource
Avatar
That's great. Regarding events on the MDI Container, I can moved the Loaded event handler to the DockSite, but what about SelectionChanged? Even if the container is recreated as needed, does that effect whether or not it will handle a SelectionChanged event?
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Use DockSite.WindowActivated instead. That will fire for all windows right now. So if the window is a DocumentWindow, you know it is now active. If the window is a ToolWindow, check its state to see if it is in a Document state. If so, that one is now active.

We plan on adding a new event in the future that fires when a new primary document is set so that this sort of "if" logic isn't necessary.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.