3
votes

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>
4
I have a similar problem - dragging with a mouse - some splitters in my grid work fine, while others jump back to original position before I can move them. Sometimes dragging them a little bit and quickly releasing the mouse button helps unblock them, but not very often. All this while just clicking on a splitter and using the keyboard - works without any problems.Filip Skakun

4 Answers

6
votes

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
votes

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.

1
votes

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.

0
votes

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