Cómo llenar la aplicación AvalonDock 2.0 solo con AnchorableWindows - sin DocumentPane

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

preguntado el 04 de septiembre de 13 a las 02:09

3 Respuestas

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);
    }

  }
}

respondido 22 nov., 18:12

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;

Respondido el 06 de Septiembre de 13 a las 01:09

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);
    }
}

respondido 01 nov., 13:14

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.