WPF 网格分割器
我在使用 WPF GridSplitter 时遇到奇怪的行为。
我将适当的 HorizontalAlignment 属性设置为拉伸,当我调整它们的大小时,GridSplitter 会跳来跳去,有时会回到原来的位置,或者只是在拖动它们时跳来跳去......还有
其他人看到或知道可能导致此问题的原因吗? ?
谢谢
这是XAML
<GridSplitter x:Name="grdTreeSplitter" Grid.Row ="1"
BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"
BorderThickness="1"
HorizontalAlignment="Stretch" Panel.ZIndex="0"
ResizeBehavior="PreviousAndNext" ResizeDirection="Rows"
SnapsToDevicePixels="False" ShowsPreview="False" UseLayoutRounding="False"
DragIncrement="1"
DragDelta="grdSideExplorerSplitter_DragDelta">
<GridSplitter.Visibility>
<MultiBinding
......
</MultiBinding>
</GridSplitter.Visibility>
</GridSplitter>
I am experiencing weird behaviour whilst using the WPF GridSplitter.
I have the appropriate HorizontalAlignment properties set to stretch and when I resize them the GridSplitter jumps around, sometimes going back to their original positions or just jumping around as I drag them.....
Does anyone else seen or know what may be causing this?
Thanks
Here is the XAML
<GridSplitter x:Name="grdTreeSplitter" Grid.Row ="1"
BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"
BorderThickness="1"
HorizontalAlignment="Stretch" Panel.ZIndex="0"
ResizeBehavior="PreviousAndNext" ResizeDirection="Rows"
SnapsToDevicePixels="False" ShowsPreview="False" UseLayoutRounding="False"
DragIncrement="1"
DragDelta="grdSideExplorerSplitter_DragDelta">
<GridSplitter.Visibility>
<MultiBinding
......
</MultiBinding>
</GridSplitter.Visibility>
</GridSplitter>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我遇到了同样的问题,发现相同的代码在 Silverlight 中工作正常,而在 WPF 中则损坏,所以我认为这可能是 WPF 的问题。我的解决方法是推出我自己的 GridSplitter 版本,该版本太大而无法放在这里,因此您可以在 我的博客。
I had the same problem and found the same code works fine in Silverlight while it is broken in WPF, so I think it might be a problem with WPF. My fix was to roll out my own version of the GridSplitter, which is too big to put here, so you can see it on my blog.
我也有同样的问题,看来我们画了很多东西。如果我们设置了 ShowsPreview 属性。当尝试更新屏幕时,用户可以将其拖动到抓取手柄之外。但用户线程应该与图形渲染线程分开,所以我不知道。如果用户选择拆分器并使用键盘上的向上和向下箭头,它也可以正常工作。啊,在写这篇文章的时候。我尝试使用更大的值来拖动增量,这似乎也有效。更好的解决方案。这是在同一方向上使用两个网格分割器(屏幕的三个部分)我不知道这是否也是您的设置。
I have the same problem it seems like we are drawing a lot of stuff. And if we have the ShowsPreview property set. The user can drag outside the grab-handle while it is trying to update the screen. But the user thread is supposed to be separate from the graphic rendering thread so I don't know. If the user selects the splitter and uses the up and down arrows on the keyboard it works fine also. Ah whilst writing this. I tried using larger values for dragincrement and that seems to work also. Better solution. This is with two gridsplitters in the same direction(three sections of screen) I don't know if that is also your setup.
当网格列中的 width="1*" 时,我的 gridsplitter 正在跳跃。
我已经设置了像素大小,它停止了跳跃。
My gridsplitter was jumping when I had width="1*" in grid columns.
I've set size in pixels and it stopped jumping.
我意识到这已经很旧了,但也许这会对某人有所帮助。我遇到的问题是,在快速分离器移动后,分离器会跳回原始位置。我的解决方案是在拆分器的
PreviewMouseUp
事件处理程序中调用CancelDrag
。警告
这可能对其他人有帮助,也可能没有帮助,因为我正在使用一个经过大量修改的派生类,具有附加功能(包括管理我自己的动作),并且我不知道它是否会有所帮助(或在所有)在一个简单的场景中。
I realize this is old, but maybe this will help someone. I was having the issue where the splitter would jump back to the original position after quick splitter moves. The solution for me was to call
CancelDrag
in the splitter'sPreviewMouseUp
event handler.Caveat
This may or may not help others, as I am working with a heavily modified derived class with additional functionality (including managing my own moves), and I have no idea if it will help (or work at all) in a simple scenario.