Question

I simply would like to fill AvalonDock application only with "Tool" windows without any document. I can manually minimize the documentpane area but if possible, I would like to fill that small area with another anchorable window so that LayoutDocumentPane's width and height are zero.

Problem from AvalonDock framework's assumption there is at least single empty DocumentPane becomes apparent in my case. Even though there is no document, the emptry space of DocumentPane is easily overlapped or underlapped by other tool windows near it. This makes some window partly invisible or under-filled.

What I tried in vain so far:

  1. Removed LayoutDocumentPane tag from DockManager declaratrion
  2. Set DockWidth and DockHeight of LayoutDocumentPane to zero
  3. Manually minimized DocumentPane and serialize the layout

Any clue will be appreciated

Was it helpful?

Solution 2

There seems like no way to do this except for changing source code. In CollectGarbage method of LayoutRoot.cs, I commented out following code and got what I wanted - AvalonDock application without any DocumentPane. If there is really no method for this, I highly suggest the author have an option for this without modifying source. Hope it helps others like me.

                if (emptyPane is LayoutDocumentPane &&
                    this.Descendents().OfType<LayoutDocumentPane>().Count(c => c != emptyPane) == 0)
                    continue;

OTHER TIPS

I remove the documents of one DocumentPane after restoring:

public static void Restore(DockingManager dockingManager, string file)
{
  if (File.Exists(file))
  {
    try
    {
      var serializer = new XmlLayoutSerializer(dockingManager);

      // Imparitive for Deserialization
      serializer.LayoutSerializationCallback += (s, args) =>
      {
        args.Content = args.Content;
      };

      serializer.Deserialize(file);

      var laToDelete = Singleton.WindowMain.DocumentPane.Children
        .OfType<LayoutAnchorable>()
        .ToList();
      for (var index = 0; index < laToDelete.Count; index++)
      {
        LayoutAnchorable layoutAnchorable = laToDelete[index];
        Singleton.WindowMain.DocumentPane.Children.Remove(layoutAnchorable);
      }
    }
    catch
    {
      File.Delete(file);
    }

  }
}

Another solution can be load the layout again, using the code below:

Dispatcher.Invoke(new Action(() =>
{
    LoadPageLayout(page);
}), DispatcherPriority.ContextIdle, null);

private void LoadPageLayout(Dashboard.ViewModel.PageViewModel selectedPage)
{
    var serializer = new Xceed.Wpf.AvalonDock.Layout.Serialization.XmlLayoutSerialize(dockingManager);
    serializer.LayoutSerializationCallback += (s, args) =>
    {
        args.Content = args.Content;
    };

    var layoutToRestore = selectedPage.GetLayout();
    if (!String.IsNullOrEmpty(layoutToRestore))
    {
        // Remove any existing LayoutDocumentPane
        var cleanedLayout = RemoveAllEmptyXmlNodes(layoutToRestore);

        StringReader textReader = new StringReader(cleanedLayout);
        serializer.Deserialize(textReader);
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top