4

我在我的 WPF 应用程序中使用 Avalon。我想要一个类似于 Visual Studio 的窗口,左侧是工具,中间是文档,右侧是属性。我设法用这段代码做到了这一点:

<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>

问题是当我调整它们中的任何一个时,它们都会调整大小以保持它们的比例。这不是我想要的,我希望它像 VS 一样,只有中间的文档窗口调整大小。

我将不胜感激任何帮助,因为我已经为此奋斗了几天:(

4

1 回答 1

7

有趣,因为我从那里开始使用 Avalon 教程,并用您的 XAML 替换了窗口的内容(顺便说一句非常相似)。你描述的问题并没有发生。

Then I realized that the tutorial uses AvalonDock 1.1.1692, while the latest release is 1.1.2691 and has the behaviour you describe.

A look at the source code shows an attached property defined by ResizingPanel called ResizeWidth, which is 1* by default => the auto resize.

If you change the first DockablePane like this:

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

You get the behaviour you wanted.

It's never great to use hard-coded widths, so I changed it to

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

after naming the inner DockableContent dc

于 2010-03-01T16:35:37.250 回答