docksite using splitcontainer refresh to original view

Docking/MDI for WPF Forum

Posted 13 years ago by Mary Fontana - Rudolph Technologies
Avatar
I have a docksite that uses splitcontainer :

 <docking:DockSite x:Name="dockSite" 
            CanDocumentWindowsRaft="True" 
            ToolWindowsHaveTitleBars="True" ToolWindowsTabPlacement="Bottom" 
            ToolWindowsSingleTabLayoutBehavior="Show" 
            ToolWindowsTabOverflowBehavior="ShrinkWithMenu" 
            CanToolWindowsClose="True" 
            CanToolWindowsRestoreToAutoHideState="True" 
            CanToolWindowsAutoHide="True" AutoHidePopupCloseAnimation="None" AutoHidePopupOpenAnimation="None" CanToolWindowsBecomeDocuments="False">
            <docking:SplitContainer Orientation="Horizontal">
                <docking:SplitContainer Orientation="Vertical">
                    <docking:ToolWindowContainer>
                        <docking:ToolWindow x:Name="topLeftWindow1" Title="Window1"  
                             CanClose="False" >
                        </docking:ToolWindow>
                        <docking:ToolWindow x:Name="topLeftWindow2" Title="Window2" 
                            CanClose="False"  >
                        </docking:ToolWindow>
                        <docking:ToolWindow x:Name="topLeftWindow3" Title="Window3"  
                            CanClose="False" >
                        </docking:ToolWindow>
                       
                    </docking:ToolWindowContainer>
                    <docking:ToolWindowContainer>
                        <docking:ToolWindow x:Name="mainPropWindow"  Title="Main Properties"
                            CanClose="False" >
                            <local:PropGridView/>
                        </docking:ToolWindow>
                    </docking:ToolWindowContainer>
                 
                </docking:SplitContainer>
                <docking:SplitContainer Orientation="Vertical">
                    <docking:ToolWindowContainer docking:DockSite.ControlSize="250, 300">
                        <docking:ToolWindow x:Name="topRightWindow" Title="Tool1" 
                            CanRaft="False" CanClose="False" CanAutoHide="True" >
                        </docking:ToolWindow>
                    </docking:ToolWindowContainer>
                    <docking:ToolWindowContainer docking:DockSite.ControlSize="250, 300">
                        <docking:ToolWindow x:Name="bottomRightWindow" Title="Tool2"
                             CanRaft="False" CanClose="False" >
                            </docking:ToolWindow>
                            <docking:ToolWindow x:Name="bottomRightWindow2" Title="Tool3" 
                             CanRaft="False" CanClose="False" >
                            </docking:ToolWindow>
                    </docking:ToolWindowContainer>
                </docking:SplitContainer>
            </docking:SplitContainer>
        </docking:DockSite>
I also set ratio of containers in the onloaded event:

 private void OnLoaded(object sender, RoutedEventArgs e)
        {
            this.ResetSplitterRatio();

           
        }

        private void ResetSplitterRatio()
        {
            IList<DependencyObject> descendents = VisualTreeHelperExtended.GetAllDescendants(this.revisionDockSite, typeof(SplitContainer));
            if (null != descendents)
            {
                foreach (SplitContainer splitContainer in descendents)
                {
                    if (splitContainer.Orientation == Orientation.Horizontal)
                        splitContainer.ResizeSlots(2.6, 1);  
                    else
                        splitContainer.ResizeSlots(2, 1);
                }
            }
        }

I also have code that programmatically adds a other tool windows that are not on intial display.
After a user floats and re-docks with tool windows possibly in a differnt container.

I would like to have a "refresh" button to set the docksite view as it looked in its initial view when first started.

Is there a way to do this?

[Modified at 08/11/2011 05:46 PM]

Comments (4)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Mary,

The easiest way might be to just save a layout (see our samples and documentation on how to save/load layouts) after your ResetSplitterRatio call then restore that layout later when you press the refresh button.


Actipro Software Support

Posted 13 years ago by Mary Fontana - Rudolph Technologies
Avatar
I added a SaveLayout() after calling the ResetSplitterRatio();

When LoadLayout() is called, it does not restore the ratio on the splitcontainer.
I tried calling ResetSpliterRatio() again after the LoadLayout, but there are no splitcontainers when it is called.

Any suggestions?


Here is part of the code

private void LoadLayout()
{
            if (dockSiteLayout != null)
            {
                this.isLoadingLayout = true;
                try
                {
                    this.layoutSerializer.LoadFromString(dockSiteLayout, dockSite);
                }
                finally
                {
                    this.isLoadingLayout = false;
                }
            }
}


 private void SaveLayout()
{
            if (this.isLoadingLayout)
                return;

            dockSiteLayout = layoutSerializer.SaveToString(dockSite);
 }

private void Refresh_Click(object sender, RoutedEventArgs e)
        {
            LoadLayout();
           // this.ResetSplitterRatio();
        }

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Mary,

Sorry, the ResizeSlots probably won't take effect right away. It requires WPF to measure and arrange the SplitContainer to update the layout. You can try adding a splitContainer.UpdateLayout() call after you resize the slots, but you may need to dispatch the call to save the layout (so it runs after the measure/arrange phase).


Actipro Software Support

Posted 13 years ago by Mary Fontana - Rudolph Technologies
Avatar
adding splitContainer.UpdateLayout() worked. Thanks
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.