WPF GridSplitter

折月煮酒 提交于 2019-11-30 20:00:22

问题


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>

回答1:


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.




回答2:


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.




回答3:


My gridsplitter was jumping when I had width="1*" in grid columns. I've set size in pixels and it stopped jumping.




回答4:


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's PreviewMouseUp 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.



来源:https://stackoverflow.com/questions/3369087/wpf-gridsplitter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!