AvalonDock
AvalonDock copied to clipboard
How can I setup the initial layout?
I'm having a little trouble setting up my layout initializer following some of the examples and tutorials I've found online. Below is similar to how I'd like my layout to be:
However, this is how it's currently looking:
Below is how I'm implementing the BeforeInsertAnchorable
method.
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
{
if (anchorableToShow == null)
{
throw new ArgumentNullException(nameof(anchorableToShow));
}
if (destinationContainer != null && destinationContainer.FindParent<LayoutFloatingWindow>() != null)
{
return false;
}
anchorableToShow.CanShowOnHover = false;
if (anchorableToShow.Content is IProjectExplorerToolViewModel or IConsoleToolViewModel)
{
var group = new LayoutAnchorGroup();
group.Children.Add(anchorableToShow);
layout.BottomSide.Children.Add(group);
anchorableToShow.ToggleAutoHide();
return true;
}
if (anchorableToShow.Content is ISceneHierarchyToolViewModel)
{
var group = new LayoutAnchorGroup();
group.Children.Add(anchorableToShow);
layout.LeftSide.Children.Add(group);
anchorableToShow.ToggleAutoHide();
return true;
}
if (anchorableToShow.Content is IPropertiesToolViewModel or IEntitySystemsToolViewModel)
{
var group = new LayoutAnchorGroup();
group.Children.Add(anchorableToShow);
layout.RightSide.Children.Add(group);
anchorableToShow.ToggleAutoHide();
return true;
}
return false;
}
And here is my LayoutRoot
<!-- LAYOUT UPDATE STRATEGY -->
<DockingManager.LayoutUpdateStrategy>
<layout:LayoutInitializer />
</DockingManager.LayoutUpdateStrategy>
<!-- LAYOUT ROOT -->
<LayoutRoot>
<LayoutPanel Orientation="Horizontal">
<LayoutPanel Orientation="Vertical">
<!-- DOCUMENTS -->
<LayoutDocumentPane />
</LayoutPanel>
<LayoutAnchorablePaneGroup DockWidth="256" Orientation="Vertical">
<LayoutAnchorablePane Name="SceneHierarchy" />
<LayoutAnchorablePane Name="EntitySystems" />
<LayoutAnchorablePane Name="Properties" />
</LayoutAnchorablePaneGroup>
<LayoutAnchorablePaneGroup DockHeight="256" Orientation="Horizontal">
<LayoutAnchorablePane Name="ProjectExplorer" />
<LayoutAnchorablePane Name="Console" />
</LayoutAnchorablePaneGroup>
</LayoutPanel>
If anyone can point me in the right direction that would be lovely. For now, I don't care much for saving/loading layouts and just want to have a layout similar to the first screenshot shown above.
I guess my issues are:
- How can I add an anchorable pane to another anchorable pane like in the first screenshot (see the project explorer and console tool windows).
- How can I resize the initial width and height of the tool windows and perhaps set a minimum and maximum?
- Also, is there a better way to ensure that anchorable panes are not automatically hidden when added to a group? This seems almost like a bug having to call
ToggleAutoHide
for each group.