Linked nested DockSites and Serialization

Docking/MDI for WPF Forum

Posted 13 years ago by Markus Henschel - Yager Development
Version: 11.1.0545
Avatar
Hi,

I tried to use the new docksite linking feature. I've got two docksites. One is the main docksite and the other is a child of a DocumentWindow in a TabbedMdiContainer. I link both docksites to be able to drag windows from the nested docksite to the main one and vice versa. This works but I don't know how to serialize the layout. Currently I serialize both docksites separately.

When I don't move windows from the nested docksite to the main docksite serialization works. But if a window from the nested docksite is docked into the main docksite this window is not there anymore after restoring the layout.

Am I doing something wrong? This is the docksite part of my xaml file.

<docking:DockSite Grid.Row="2" x:Name="dockSite" CanDocumentWindowsRaft="True">

    <!-- NOTE: Split containers can contain two elements, which are typically ToolWindowContainers (with 1 or more tool windows)
                and one (and only one) Workspace -->
    <docking:SplitContainer Orientation="Horizontal" x:Name="LeftAndResourcesContainer"
                            docking:DockSite.ControlSize="800,600">
        <docking:SplitContainer Orientation="Vertical" x:Name="MainAndSequencerContainer"
                                docking:DockSite.ControlSize="600,600">
            <docking:SplitContainer Orientation="Horizontal" x:Name="NavigationAndMainContainer"
                                    docking:DockSite.ControlSize="400,400">
                <docking:ToolWindowContainer x:Name="NavigationContainer"
                                                docking:DockSite.ControlSize="200,400">
                    <docking:ToolWindow x:Name="ComponentTreeViewWindow" Title="Scene View">
                        <UserControls:WPFComponentTree x:Name="ComponentTreeView"/>
                    </docking:ToolWindow>
                    <docking:ToolWindow x:Name="LogicalTreeViewWindow" Title="Logical View">
                        <UserControls:LogicalTree x:Name="LogicalTreeView"/>
                    </docking:ToolWindow>
                    <docking:ToolWindow x:Name="HistoryTreeViewWindow" Title="History">
                        <UserControls:WPFHistoryView x:Name="HistoryView"/>
                    </docking:ToolWindow>
                </docking:ToolWindowContainer>
                <docking:SplitContainer  Orientation="Vertical" x:Name="MainAndLogContainer">
                    <docking:Workspace x:Name="MdiWorkspace">
                        <docking:TabbedMdiHost x:Name="MdiTabbedHost" CanDocumentsDockLeft ="True">
                            <docking:TabbedMdiContainer x:Name="TabbedMdiContainer">
                                <!-- render views -->
                                <docking:DocumentWindow x:Name="RenderViewsWindow" Title="Render Views" CanAttach="True">
                                    <docking:DockSite x:Name="RenderViewsDockSite" UseHostedAutoHidePopups="False" >
                                    <docking:SplitContainer x:Name="RenderViewsContainer"  Orientation="Vertical"
                                        docking:DockSite.ControlSize="400,400">
                                        <docking:SplitContainer Orientation="Horizontal" x:Name="SplitContainerTop">
                                            <docking:ToolWindowContainer x:Name="LeftViewContainer">
                                                <!-- Left -->
                                                <docking:ToolWindow x:Name="LeftView" Title="Left">
                                                    <WindowsFormsHost x:Name="RenderViewLeft"
                                                                        ContextMenu="{StaticResource 
                                                                        OrthogonalRenderViewContextMenu}">
                                                        <wf:Panel Name="RenderViewControlLeft"/>
                                                    </WindowsFormsHost>
                                                </docking:ToolWindow>
                                            </docking:ToolWindowContainer>
                                            <docking:ToolWindowContainer x:Name="TopViewContainer">
                                                <!-- Top -->
                                                <docking:ToolWindow x:Name="TopView" Title="Top">
                                                    <WindowsFormsHost x:Name="RenderViewTop"
                                                        ContextMenu="{StaticResource 
                                                                        OrthogonalRenderViewContextMenu}">
                                                        <wf:Panel Name="RenderViewControlTop"/>
                                                    </WindowsFormsHost>
                                                </docking:ToolWindow>
                                            </docking:ToolWindowContainer>
                                        </docking:SplitContainer>
                                        <docking:SplitContainer Orientation="Horizontal" x:Name="SplitContainerBottom">
                                            <docking:ToolWindowContainer x:Name="FrontViewContainer">
                                                <!-- Front -->
                                                <docking:ToolWindow x:Name="FrontView" Title="Front">
                                                    <WindowsFormsHost x:Name="RenderViewFront"
                                                                        ContextMenu="{StaticResource 
                                                                        OrthogonalRenderViewContextMenu}">
                                                        <wf:Panel Name="RenderViewControlFront"/>
                                                    </WindowsFormsHost>
                                                </docking:ToolWindow>
                                            </docking:ToolWindowContainer>
                                            <docking:ToolWindowContainer x:Name="PerspectiveViewContainer">
                                                <!-- Perspective -->
                                                <docking:ToolWindow x:Name="PerspectiveView" Title="Perspective">
                                                        <WindowsFormsHost x:Name="RenderViewPerspective"
                                                                            ContextMenu="{StaticResource 
                                                                            PerspectiveRenderViewContextMenu}">
                                                            <UserControls:RenderPanelHost Name="RenderViewControlPerspective"/>
                                                    </WindowsFormsHost>
                                                </docking:ToolWindow>
                                            </docking:ToolWindowContainer>
                                        </docking:SplitContainer>
                                    </docking:SplitContainer>
                                    </docking:DockSite>
                                </docking:DocumentWindow>
                                <docking:ToolWindow x:Name="PropertyGridWindow" Title="Properties">
                                    <UserControls:WPFPropertyGrid x:Name="PropertyGrid"/>
                                </docking:ToolWindow>
                                <docking:ToolWindow x:Name="SnapshotWindow" Title="Snapshot">
                                    <UserControls:WPFSnapshotView x:Name="SnapshotView"/>
                                </docking:ToolWindow>
                            </docking:TabbedMdiContainer>
                        </docking:TabbedMdiHost>
                    </docking:Workspace>
                    <docking:ToolWindowContainer x:Name="LogContainer"
                                                    docking:DockSite.ControlSize="400,100">
                        <docking:ToolWindow x:Name="Log" Title="Log">
                            <UserControls:LogWindow x:Name="LogView"/>
                        </docking:ToolWindow>
                    </docking:ToolWindowContainer>
                </docking:SplitContainer>
            </docking:SplitContainer>
            <docking:ToolWindowContainer docking:DockSite.ControlSize="600,150">
                <docking:ToolWindow Title="Sequencer" x:Name="SequencerWindow">
                    <UserControls:WPFSequencerView x:Name="SequencerView"/>
                </docking:ToolWindow>
            </docking:ToolWindowContainer>
        </docking:SplitContainer>
        <docking:ToolWindowContainer x:Name="ResourcesAndMacroContainer"
                                        docking:DockSite.ControlSize="200,600">
            <docking:ToolWindow Title="Resources" x:Name="ResourceWindow">
                <UserControls:WPFResourceView x:Name="ResourceView"/>
            </docking:ToolWindow>
            <docking:ToolWindow Title="Macro Recorder" x:Name="MacroRecorderView">
                <UserControls:WPFCommandRecorderControl x:Name="MacroRecorder"/>
            </docking:ToolWindow>
            <docking:ToolWindow Title="Sequencer Overview" x:Name="SequencerOverviewWindow">
                <UserControls:WPFSequencerStatistic x:Name="SequencerStatisticView"/>
            </docking:ToolWindow>
            <docking:ToolWindow Title="Edit Keyframe" x:Name="EditKeyframeWindow">
                <UserControls:EditKeyframeDialog x:Name="EditKeyframeView"/>
            </docking:ToolWindow>
            <!-- Message View -->
            <docking:ToolWindow Title="Message mappings" x:Name="MessageManagerWindow">
                <UserControls:MessageView x:Name="MessageManagerView"/>
            </docking:ToolWindow>
        </docking:ToolWindowContainer>
    </docking:SplitContainer>
</docking:DockSite>

Comments (2)

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

You would have to serialize the DockSites separately. Keep in mind that by default the serializer will only restore the layout for windows that exist in the DockSite. So if your outer DockSite has ToolWindow1 and ToolWindow2 and your inner DockSite has ToolWindow3 and ToolWindow4, then restoring a layout to your outer DockSite that includes TW1, TW2, and TW3 will not move TW3 from the inner DockSite to the outer DockSite.

You can use the DockingWindowDeserializing event of our serializer to know when a ToolWindow needs to be moved. The event arguments will specify the associated window by name (via e.Node.Name) and the window itself (via e.Window). If the latter is null, then you know the window was not found. In this case, you'd need to remove the associated tool window from the inner DockSite and add to the outer DockSite (or vice versa).

If you get stuck feel free to put together a small sample project that reproduces your issue and email it over and we can help out. Be sure to remove any executables or change the extension of the zip file to ensure it gets past our email filters.


Actipro Software Support

Posted 13 years ago by Markus Henschel - Yager Development
Avatar
Thanks. It works as you said. When it occurs that args.Window is null in my DockingWindowDeserializing event hanlder I search all linked docksites for the window with args.Node.Name and move it to the docksite that is currently being serialized by calling MoveToLinkedDockSite on that window.
The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.