Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
280
ContentPanes will not be saved with DockManager.SaveLayout
posted

I have a problem trying to save the Layout of my application with the SaveLayout Method of the DockManager. I´m adding the ContentPanes to the DocumentContentHost programatically, so no definitions are made in the xaml code. The Panes which will be added have a Header, Name and SerializationId set. The Xaml File of the ContentPane classes also have the SaveInLayout="True" property set.

Am I missing something i need to do or will the ContentPanes of the DockManager only be saved when they are defined within the xaml code of the MainWindow.xaml?

All my Panes use ContentPane as base class. Inside my classes i´m using a WindowsFormContentHost or a derived XamDataGrid or something like that. So, not very simple controls on every pane.

Here are the code parts of my application which should illustrate my approach.

 

The DockManager is nested inside: XamRibbonWindow -> RibbonWindowContentHost -> Grid -> XamDockManager

<igDock:XamDockManager Grid.Column="1" x:Name="tpnMainWindowDockManager" ActivePaneChanged="tpnMainWindowDockManager_ActivePaneChanged">
                <igDock:DocumentContentHost>
                    <igDock:SplitPane>
                        <igDock:TabGroupPane x:Name="tpnDocumentcontentHost" TabStripPlacement="Top" AllowDrop="True">
                        </igDock:TabGroupPane>
                    </igDock:SplitPane>
                </igDock:DocumentContentHost>
            </igDock:XamDockManager>

 

This is the Xaml code from one of my ContentPane classes which uses a WindowsFormsHost in order to display an ActiveX Object.

<DockManager:ContentPane x:Class="TaiPanNet.ChartPane"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:DockManager="clr-namespace:Infragistics.Windows.DockManager;assembly=InfragisticsWPF4.DockManager.v10.3"
        Loaded="ContentPaneLoaded"
        SaveInLayout="True" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="155" d:DesignWidth="243" Name="ContentPaneChart" Header="Chart">
    <DockPanel Name="dockPanel1" >
        <WindowsFormsHost HorizontalAlignment="Stretch" Name="wfhOCXChart" VerticalAlignment="Stretch" />
    </DockPanel>
</DockManager:ContentPane>

 

The serializationId, header and name will be set when an instance of the class is created. Here the  code sample of saving the Layout:

        private void TPNMainWindow_Closed(object sender, EventArgs e)
        {
            try
            {
                var fs = new FileStream("Layout.xml", FileMode.Create, FileAccess.Write);
                tpnMainWindowDockManager.SaveLayout(fs);
            }
            catch (Exception ex)
            {
                string ExceptionMessage = ex.Message;
            }
        }

 

And here is the way i add the new ContentPane to the DockManager:

        private void btOpenSkyChart_Click(object sender, RoutedEventArgs e)
        {
            ChartPane cp = new ChartPane(21725258) { Header = "Sky", SerializationId = "test", Name = "Sky"};
            tpnDocumentcontentHost.Items.Add(cp);
            cp.Activate();
        }

Parents
No Data
Reply
  • 54937
    Offline posted

    What specifically is the problem you are having? If those panes are in the xamDockManager or its DocumentContentHost when the SaveLayout is called (which in your case is from the Closed event of the window) then that information will be in the layout file. You can look at the layout file (it's just an xml file) to know for sure what is saved.

    Now when you load the layout you will have to do some extra work since presumably those panes won't exist when the layout is loaded. When the dockmanager encounters a pane in a layout file that it doesnt' recognize it creates a new ContentPane and raises the InitializePaneContent event at which point you are expected to initialize the content, etc of that pane (usually using the SerializationId to store information about the pane). In your case, you'll need to handle that and create the appropriate derived pane and set the e.NewPane to that derived pane.

Children