为什么拆分器第一次移动时 AvalonDock 窗格的高度会塌陷?

问题描述

C#、WPF、AvalonDock v 4.0.0.0。我在 useLocalStorage 中垂直排列了三个 AnchorablePanes。当用户第一次调整任一分离器时,所有三个 LayoutPanel 的高度或垂直位置都会突然改变。据我所知,这是怎么回事:

当一个分离器被移动时,最远的AnchorablePanes(即应该不受移动影响的那个)折叠到它的最小高度。剩下的两个调整以填充空间,保持彼此之间正确的高度比例。即

如果移动顶部分隔符,AnchorablePane 3 会折叠,AnchorablePane 1 和 2 会展开以填充空间。

如果移动底部分隔符,AnchorablePanes 1 会折叠,AnchorablePane 2 和 3 会展开以填充空间。

AnchorablePanes 不只是折叠以适应内容。在我的实际应用中,它们确实有内容,但会被遮挡。

enter image description here

一旦发生这种情况,此后的行为是正常的。就好像初始显示与底层参数不匹配,因此第一次重新计算时会进行更正。

我们知道是什么导致了这种情况或如何预防吗?以下最小示例演示。只需运行此程序并移动任一拆分器即可。

AnchorablePanes

 <Window x:Class="TestAvalon.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:dock="http://schemas.xceed.com/wpf/xaml/avalondock"
          Title="MainWindow" Height="450" Width="800">
      <Grid>
          <dock:DockingManager x:Name = "Dockman">
              <dock:LayoutRoot x:Name = "_layoutRoot" >
                  <dock:LayoutPanel Orientation="Vertical">
                      <dock:LayoutAnchorablePaneGroup Orientation="Vertical">
                          <dock:LayoutAnchorablePane>
                              <dock:LayoutAnchorable Title = "TEST PANE 1">
                              </dock:LayoutAnchorable >
                          </dock:LayoutAnchorablePane >
                          <dock:LayoutAnchorablePane>
                              <dock:LayoutAnchorable Title = "TEST PANE 2">
                              </dock:LayoutAnchorable >
                          </dock:LayoutAnchorablePane >
                          <dock:LayoutAnchorablePane>
                              <dock:LayoutAnchorable Title = "TEST PANE 3">
                              </dock:LayoutAnchorable >
                          </dock:LayoutAnchorablePane >
                      </dock:LayoutAnchorablePaneGroup>
                  </dock:LayoutPanel>
              </dock:LayoutRoot >
          </dock:DockingManager>
      </Grid>
  </Window>

解决方法

虽然我不知道是什么导致了这种行为,也不知道在使用 Xceed 的 AvalonDock 时如何避免它,但我通过使用 Dirkster's AvalonDock 叉解决了这个问题。我使用的是 4.50.2 版本,只需对代码进行最少的更改即可在两个库之间切换。 Dirkster 的 AvalonDock 没有表现出问题中描述的问题行为。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...