How to configure Avalon docking manager to resize, for example VS?

I am using Avalon in my WPF application. I want a window similar to the Visual Studio window, Tools on the left, then the documents in the middle and Properties on the right. I managed to do this with this code:

<Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock" xmlns:local="clr-namespace:WpfApplication1" Title="Window1" Height="600" Width="800"> <Grid> <ad:DockingManager x:Name="dockManager" RenderTransformOrigin="0,0"> <ad:ResizingPanel Orientation="Vertical"> <ad:ResizingPanel Orientation="Horizontal" > <ad:DockablePane> <ad:DockableContent Title="Toolbox" Width="100"> <TextBox /> </ad:DockableContent> </ad:DockablePane> <ad:DocumentPane x:Name="documentsHost" OverridesDefaultStyle="True"> <ad:DocumentContent Title="File1.doc"> <RichTextBox/> </ad:DocumentContent > <ad:DocumentContent Title="File2.doc"> <RichTextBox/> </ad:DocumentContent > </ad:DocumentPane> <ad:DockablePane> <ad:DockableContent Title="Project Explorer"> <TextBox /> </ad:DockableContent> </ad:DockablePane> </ad:ResizingPanel> <ad:DockablePane> <ad:DockableContent Title="Output"> <TextBox /> </ad:DockableContent> </ad:DockablePane> </ad:ResizingPanel> </ad:DockingManager> </Grid> </Window> 

The problem is that when I resize any of them, they resize to preserve their share. This is not what I want, I want it to look like VS, where only the document window on average changes with.

I would be grateful for any help, since I have been fighting this for several days :(

+4
source share
1 answer

It's funny because I started with the Avalon tutorial from there and replaced the contents for the window with your XAML (very similar, by the way), and the problem you are describing is not happening.

Then I realized that the tutorial uses AvalonDock 1.1.1692, and the latest version is 1.1.2691, and you describe the behavior.

Look at the source code showing the attached property specified by the ResizingPanel with the name ResizeWidth, which by default is 1 * => autosize.

If you change the first DockablePane as follows:

 <ad:DockablePane ad:ResizingPanel.ResizeWidth="100" > 

You will get the desired behavior.

Hard-coded widths cannot be used, so I changed it to

 <ad:DockablePane ad:ResizingPanel.ResizeWidth="{Binding ElementName=dc, Path=Width}" > 

after the name of the internal DockableContent dc

+6
source

Source: https://habr.com/ru/post/1302747/


All Articles