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

Error with HitTestScrollBar #34

Closed
punker76 opened this issue Feb 18, 2013 · 1 comment
Closed

Error with HitTestScrollBar #34

punker76 opened this issue Feb 18, 2013 · 1 comment

Comments

@punker76
Copy link
Owner

Original author: mitchell...@gmail.com (April 07, 2011 11:48:11)

There is an issue with the HitTestScrollBar code.

You current have the line:

hit.VisualHit.GetVisualAncestor<System.Windows.Controls.Primitives.ScrollBar>() != null;

This checks to see if the visual ancestor of the hit item is the a scroll bar. However what it doesn't check for is if its visible or not.

I've changed the version in my branch to be:

static bool HitTestScrollBar(object sender, MouseButtonEventArgs e)
{
    HitTestResult hit = VisualTreeHelper.HitTest((Visual)sender, e.GetPosition((IInputElement)sender));

    if (hit == null)
        return false;
    else
    {
        var scrollBar = hit.VisualHit.GetVisualAncestor<System.Windows.Controls.Primitives.ScrollBar>();
        return scrollBar != null && scrollBar.Visibility == Visibility.Visible;
    }
}

Without the extra visibility check the scroll bar is reporting it is being hit when it isn't visible, and therefore stops the user from dragging the item.

Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=34

@punker76
Copy link
Owner Author

From rdingw...@gmail.com on January 05, 2013 15:16:07
Thanks this fix was just what I needed. (Please ignore deleted comment about GridViews)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant