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
795
LoadLayout fails
posted

2010 Vol 2, 3.5 library

I get the error: Data at the root level is invalid. Line 1, position 1.

I created a new app. Copied the dock manager xaml from your first dockmanager sample. Also, I gave the splitpanes a unique name. I added ONLY the following code:

 public MainWindow()
{
InitializeComponent();
//
this.Closed += new EventHandler(MainWindow_Closed);
this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
}
<
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
if (File.Exists("layout.xml")) { this.DockManager.LoadLayout("layout.xml");
}
}
void MainWindow_Closed(object sender, EventArgs e)
{
using (FileStream fs = new FileStream("layout.xml", FileMode.Create, FileAccess.Write))
{
this.DockManager.SaveLayout(fs);
}
}

The xml file being created is:

<?xml version="1.0" encoding="utf-8"?>
<xamDockManager version="10.2.20102.1014">
  <contentPanes>
    <contentPane name="leftEdgeDock" location="DockedLeft" />
    <contentPane name="rightEdgeDock" location="DockedRight" />
  </contentPanes>
  <panes>
    <splitPane name="SplitPane1" splitterOrientation="Vertical" location="DockedLeft">
      <contentPane name="leftEdgeDock" />
    </splitPane>
    <splitPane name="SplitPane2" splitterOrientation="Vertical" location="DockedRight">
      <contentPane name="rightEdgeDock" />
    </splitPane>
  </panes>
</xamDockManager>

Parents Reply Children
No Data