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
1070
PersistenceManager save and load status of ContentPanes
posted

The MainWindow of my application is an XamRibbonWindow and its RibbonWindowContentsHost.Content is an XamDockManager. The XamDockManager contains many static and dynamic ContentPane controls within a TabGroupPane. Some of the ContentPane controls get added at run-time and some are added at design time. I would like to save the status of the static (not dynamic) ContentPanes at shutdown such that when the app is restarted where they are docked and if they are pinned is recreated. If I move a ContentPane from being docked on the left to being docked on the right and then shutdown and reopen the application this ContentPane is now displayed on the right side.

So is it possible to configure the PersistenceManager to only save and load the status of specific ContentPanes for where they are docked and if they are pinned?

Thanks,

   -eric

Parents
No Data
Reply
  • 1070
    posted

    OK I tried to create a simple WPF project to try and figure this out. When the RibbonWindow is closing I save the persistence file and on RibbonWindow Initialized I load the persistence file. This is remembering if the ContentPane is Pinned or not Pinned but if I dock it on the right side and close and reopen it does not remember the last docked location and its docked on the left at start up. So far I can only get the IsPinned property to persist correctly. Can anyone offer any advice as to how I can get it to remember the dock location? I have tried to persist the DockManager and the RibbonWindow (which is why these objects are named in the XAML) but when the app loads the DockManager is blank and I can not see the ContentPane. So far persisting the cpMapContents ContentPane is all that seems to work (a little).

    I have the following XAML and C# code-behind.

    <igRibbon:XamRibbonWindow .... x:Name="ribbonWindow">

      <igRibbon:RibbonWindowContentHost>
     
        <igRibbon:RibbonWindowContentHost.Ribbon>  

          <igRibbon:XamRibbon x:Name="ribbon" DockPanel.Dock="Top" ApplicationMenuMode="Office2010">

            <igRibbon:RibbonTabItem Header="Home">

            </igRibbon:RibbonTabItem>

          </igRibbon:XamRibbon>

        </igRibbon:RibbonWindowContentHost.Ribbon>  

        <igRibbon:RibbonWindowContentHost.Content>

          <igDock:XamDockManager x:Name="dockManager">

            <igDock:XamDockManager.Panes>
     
              <igDock:SplitPanes SplitterOrientation="Horizontal" igDock:XamDockManager.InitialLocation"DockedLeft" Width="300">

                <igDock:TabGroupPane>

                  <igDock:ContentPane x:Name="cpMapContents" Header="Map Contents" AllowInDocumentHost="False" IsPnned="True" SerializationId="cpMapContents" />

                </igDock:TabGroupPane>

              </igDock:SplitPanes>

            </igDock:XamDockManager.Panes>

          </igDock:XamDockManager>

        </igRibbon:RibbonWindowContentHost.Content>

      </igRibbon:RibbonWindowContentHost>

    </igRibbon:XamRibbonWindow>

    ----------------------------

    public partial class MainWindow : XamRibbonWindow {

      public MainWindow(){
        InitializeComponent();
      }

      private const string _fileName = @"C:\temp\data.txt";

      private void XamRibbonWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
        using (MemoryStream memoryStream = PersistenceManager.Save(cpMapContents)) {
          using (FileStream fileStream = new FileStream(_fileName, FileMode.Create, FileAccess.Write)) {
            memoryStream.WriteTo(fileStream);
          }
        }
      }

      private void XamRibbonWindow_Initialized(object sender, EventArgs e) {
        If (File.Exists(_fileName)) {
          using (FileStream fileStream = new FileStream(_fileName, FileMode.Open)) {
            PersistenceManager.Load(cpMapContents, fileStream);
          }
        }
      }

    }

Children