Question

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

Posted 2 years ago by Avatar Craig - Varigence, Inc.

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 2 years ago]


Comments (1)

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA

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
Information The latest build of this product (2014.1 build 0601) was released 26 days ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.