Repository navigation
How to find out whether the Tool is Docked as a Document? #307
Copy link
Copy link
Open
Description
Within my ToolViewModel, how do I know if the tool is docked as a Document? Or if it is floating for example?
I made a tweak in the LayoutInitializer. I've changed PaneLocation enum, adding Floating and Document options:
public void AfterInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableShown)
{
// If this is the first anchorable added to this pane, then use the preferred size.
var tool = anchorableShown.Content as ITool;
if (tool != null)
{
var anchorablePane = anchorableShown.Parent as LayoutAnchorablePane;
if (anchorablePane != null && anchorablePane.ChildrenCount == 1)
{
switch (tool.PreferredLocation)
{
case PaneLocation.Left:
case PaneLocation.Right:
anchorablePane.DockWidth = new GridLength(tool.PreferredWidth, GridUnitType.Pixel);
break;
case PaneLocation.Bottom:
anchorablePane.DockHeight = new GridLength(tool.PreferredHeight, GridUnitType.Pixel);
break;
case PaneLocation.Floating:
{
anchorableShown.FloatingHeight = tool.PreferredHeight;
anchorableShown.FloatingWidth = tool.PreferredWidth;
var window = Application.Current.MainWindow;
var screen = System.Windows.Forms.Screen.FromHandle(new WindowInteropHelper(window).Handle);
anchorableShown.FloatingTop = (screen.WorkingArea.Height / 2d) - (anchorableShown.FloatingHeight / 2d);
anchorableShown.FloatingLeft = (screen.WorkingArea.Width / 2d) - (anchorableShown.FloatingWidth / 2d);
anchorableShown.Float();
break;
}
case PaneLocation.Document:
anchorableShown.DockAsDocument();
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
}
However, MVVM in Avalon is fairly difficult, so I couldn't figure it out how to find out whether my ToolViewModel is docked as document.
Any insights?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
Dirkster99 commentedon Mar 17, 2019
Here is an insight: xceedsoftware/wpftoolkit#1437