How can I maintain the layouts of nested docksites at runtime?

Docking/MDI for WPF Forum

Posted 12 years ago by Craig - Varigence, Inc.
Version: 12.1.0562
Avatar

I'm looking to create a MDI interface where DocumentWindows are within a DockSite, and each DocumentWindow hosts its own DockSite. I've been able to mostly piece this together using the NestedDockSites and MvvmDocumentWindows demos.

However, I have a problem where the DocumentWindows' docksites aren't maintaining their state. For example, let's say I have Document 1 and Document 2. In Document 1, I arrange its inner Tool Windows so they're vertically side by side. I then switch to Document 2 and arrange its inner Tool Windows so they're horizontally side by side. When I switch back to Document 1, I expect its inner tool windows to still be arranged vertically but instead, they appear horizontally, matching Document 2's inner layout.

How can I maintain the inner layouts of these documents?

To repro:

1. Replace the DocumentItemStyle in QuickStart\MvvmDocumentWindows\Views\MainView.xml with this:

       <Style x:Key="DocumentItemStyle" TargetType="docking:DocumentWindow" BasedOn="{StaticResource DockingItemStyle}">
	    <Setter Property="FileName" Value="{Binding FileName}" />
	    <Setter Property="IsReadOnly" Value="{Binding IsReadOnly}" />
            <Setter
                Property="ContentTemplate"
                >
                <Setter.Value>
                    <DataTemplate>
                        <docking:DockSite x:Name="innerDockSite1" themes:ThemeManager.Theme="CustomGreen">
                            <docking:ToolWindowContainer>
                                <docking:ToolWindow Title="Text">
                                    <SyntaxEditor:SyntaxEditor
                                        BorderThickness="0"
                                        >
                                        <Implementation:EditorDocument>
                                            <![CDATA[Sample document.]]>
                                        </Implementation:EditorDocument>
                                    </SyntaxEditor:SyntaxEditor>
                                </docking:ToolWindow>
                                <docking:ToolWindow Title="Designer">
                                    <Rectangle
                                        Fill="Red"
                                        />
                                </docking:ToolWindow>
                            </docking:ToolWindowContainer>
                        </docking:DockSite>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
	</Style>

2. Run the MvvmDocumentWindows sample and create two documents. 

3. In Document 1, arrange the inner tool windows vertically side by side

4. In Document 2, arrange the inner tool windows horizontally side by side.

5. Switch back to Document 1 and notice that the tool window are now arrange horizontally as well.

 

Note that I tried setting the DockSite's ItemContainerRetentionMode property to Wrapped, but that had no impact.

[Modified 12 years ago]

Comments (1)

Answer - Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Craig,

Setting ContentTemplate as you are won't work.  You need to either go in ImplicitTemplates.xaml and replace the DataTemplate's content there for TextDocumentItemViewModel or go into the TextDocumentItemView.xaml and put your content in there.

Also, be sure to set ItemContainerRetentionMode="Wrapped" on your root DockSite in MainView.xaml.

If you do those two things, it should work.


Actipro Software Support

The latest build of this product (v24.1.2) was released 0 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.