Dirkster99 / AvalonDock

Our own development branch of the well known WPF document docking library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Try set Content Control of LayoutContet In LayoutSerializationCallback, but no panel shows up

KaivnD opened this issue · comments

commented

Hi everyone! I'm trying to implement layout restore in my app, but I got some troubles.
I found similar issue #397, but it's not helping with this.

here is xml content

<?xml version="1.0"?>
<LayoutRoot>
  <RootPanel Orientation="Horizontal">
    <LayoutPanel Orientation="Vertical">
      <LayoutDocumentPane>
      </LayoutDocumentPane>
    </LayoutPanel>
    <LayoutAnchorablePaneGroup Orientation="Vertical" DockWidth="250">
      <LayoutAnchorablePane DockWidth="250">
        <LayoutAnchorable Title="AssetExplorer" IsSelected="True"
          ContentId="ProjectAssetExplorerPanel" />
      </LayoutAnchorablePane>
      <LayoutAnchorablePane>
        <LayoutAnchorable Title="PropertyGrid" IsSelected="True" ContentId="PropertyGridPanel" />
        <LayoutAnchorable Title="ProjectSetting" ContentId="ProjectSettingPanel" />
      </LayoutAnchorablePane>
    </LayoutAnchorablePaneGroup>
  </RootPanel>
  <TopSide />
  <RightSide />
  <LeftSide />
  <BottomSide />
  <FloatingWindows />
  <Hidden />
</LayoutRoot>

this layout should be like this
WcV7LfAJuf

here is serialization callback

serializer.LayoutSerializationCallback += (s, e) =>
{
    var item = e.Model;
    if (string.IsNullOrEmpty(item.ContentId)) return;    
    if (!RecreatePanelContent(item.ContentId, out FrameworkElement element)) return;
    item.Content = element; // this line will make everything disppear, but I what to restore panel content here.
};

here is xaml part

<avalon:DockingManager
    Name="DockRoot"
    AllowMixedOrientation="True"
    GridSplitterHeight="2"
    GridSplitterWidth="2" />
commented

sorry, my bad. I forgot to show all panel after deserialize

  serializer.Deserialize(stream);

  foreach(var item in GetAllAnchorables())
  {
      item.Show();
  }