Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
KaivnD opened this issue Jul 12, 2023 · 1 comment

Comments

@KaivnD
Copy link

KaivnD commented Jul 12, 2023

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" />
@KaivnD
Copy link
Author

KaivnD commented Jul 12, 2023

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

  serializer.Deserialize(stream);

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

@KaivnD KaivnD closed this as completed Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant