Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scrolling issues if ScrollViewer CanContentScroll is set true #357

Merged
merged 1 commit into from
Oct 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/GongSolutions.WPF.DragDrop/DragAdorner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public DragAdorner(UIElement adornedElement, UIElement adornment, Point translat
this.m_Adornment = adornment;
this.IsHitTestVisible = false;
this.Effects = effects;
// another flicker fix
this.UpdateLayout();
}

public Point Translation { get; private set; }
Expand All @@ -25,7 +23,7 @@ public DragAdorner(UIElement adornedElement, UIElement adornment, Point translat

public Point MousePosition
{
get { return this.m_MousePosition; }
get => this.m_MousePosition;
set
{
if (this.m_MousePosition != value)
Expand Down Expand Up @@ -121,10 +119,7 @@ protected override Size MeasureOverride(Size constraint)
return this.m_Adornment.DesiredSize;
}

protected override int VisualChildrenCount
{
get { return 1; }
}
protected override int VisualChildrenCount => 1;

private readonly AdornerLayer m_AdornerLayer;
private readonly UIElement m_Adornment;
Expand Down
36 changes: 32 additions & 4 deletions src/GongSolutions.WPF.DragDrop/DragDrop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,51 @@ private static void Scroll(DropInfo dropInfo, DragEventArgs e)
{
if (position.X >= scrollViewer.ActualWidth - scrollMargin && scrollViewer.HorizontalOffset < scrollViewer.ExtentWidth - scrollViewer.ViewportWidth)
{
scrollViewer.LineRight();
if (scrollViewer.CanContentScroll)
{
scrollViewer.LineRight();
}
else
{
scrollViewer.ScrollToHorizontalOffset(scrollViewer.HorizontalOffset + 4);
}
}
else if (position.X < scrollMargin && scrollViewer.HorizontalOffset > 0)
{
scrollViewer.LineLeft();
if (scrollViewer.CanContentScroll)
{
scrollViewer.LineLeft();
}
else
{
scrollViewer.ScrollToHorizontalOffset(scrollViewer.HorizontalOffset - 4);
}
}
}

if (scrollingMode == ScrollingMode.Both || scrollingMode == ScrollingMode.VerticalOnly)
{
if (position.Y >= scrollViewer.ActualHeight - scrollMargin && scrollViewer.VerticalOffset < scrollViewer.ExtentHeight - scrollViewer.ViewportHeight)
{
scrollViewer.LineDown();
if (scrollViewer.CanContentScroll)
{
scrollViewer.LineDown();
}
else
{
scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset + 4);
}
}
else if (position.Y < scrollMargin && scrollViewer.VerticalOffset > 0)
{
scrollViewer.LineUp();
if (scrollViewer.CanContentScroll)
{
scrollViewer.LineUp();
}
else
{
scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset - 4);
}
}
}
}
Expand Down