gpt4 book ai didi

wpf - 如何设置 Avalon 对接管理器来像 VS 一样调整大小?

转载 作者:行者123 更新时间:2023-12-04 13:44:01 25 4
gpt4 key购买 nike

我在我的 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 一样,其中只有中间的文档窗口可以调整大小。

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

最佳答案

有趣,因为我是从 there 的 Avalon 教程开始的并用您的 XAML 替换窗口的内容(顺便说一下,非常相似)。并且您描述的问题不会发生。

然后我意识到本教程使用 AvalonDock 1.1.1692,而最新版本是 1.1.2691 并且具有您描述的行为。

查看源代码显示了由 ResizingPanel 定义的名为 ResizeWidth 的附加属性,默认情况下为 1* => 自动调整大小。

如果您像这样更改第一个 DockablePane:

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

你得到你想要的行为。

使用硬编码宽度从来都不是很好,所以我把它改成了
<ad:DockablePane ad:ResizingPanel.ResizeWidth="{Binding ElementName=dc, Path=Width}" >

命名内部 DockableContent dc 后

关于wpf - 如何设置 Avalon 对接管理器来像 VS 一样调整大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2356432/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com