Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 328775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:31:36+00:00 2026-05-12T09:31:36+00:00

I have a WPF app that has a ListBox . The drag mechanism is

  • 0

I have a WPF app that has a ListBox. The drag mechanism is already implemented, but when the list is too long and I want to move an item to a position not visible, I can’t.

For example, the screen shows 10 items. And I have 20 items. If I want to drag the last item to the first position I must drag to the top and drop. Scroll up and drag again.

How can I make the ListBox auto scroll?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:31:36+00:00Added an answer on May 12, 2026 at 9:31 am

    Got it. Used the event DragOver of the ListBox, used the function found here to get the scrollviewer of the listbox and after that its just a bit of juggling with the Position.

    private void ItemsList_DragOver(object sender, System.Windows.DragEventArgs e)
    {
        ListBox li = sender as ListBox;
        ScrollViewer sv = FindVisualChild<ScrollViewer>(ItemsList);
    
        double tolerance = 10;
        double verticalPos = e.GetPosition(li).Y;
        double offset = 3;
    
        if (verticalPos < tolerance) // Top of visible list?
        {
            sv.ScrollToVerticalOffset(sv.VerticalOffset - offset); //Scroll up.
        }
        else if (verticalPos > li.ActualHeight - tolerance) //Bottom of visible list?
        {
            sv.ScrollToVerticalOffset(sv.VerticalOffset + offset); //Scroll down.    
        }
    }
    
    public static childItem FindVisualChild<childItem>(DependencyObject obj) where childItem : DependencyObject
    {
        // Search immediate children first (breadth-first)
        for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
        {
            DependencyObject child = VisualTreeHelper.GetChild(obj, i);
    
            if (child != null && child is childItem)
                return (childItem)child;
    
            else
            {
                childItem childOfChild = FindVisualChild<childItem>(child);
    
                if (childOfChild != null)
                    return childOfChild;
            }
        }
    
        return null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is an interesting conundrum. We have a WPF app that has a Vista-like
I have a Windows Forms app, that has a single ElementHost containing a WPF
In my WPF app, I have a feedback control that I want to appear
Context: I have a WPF App that uses certain unmanaged DLLs in the D:\WordAutomation\MyApp_Source\Executables\MyApp
I have a wpf app that shows 5 different usercontrols as you go through
I have a WPF app with a listbox and a contentcontrol. The contentcontrol content
I have a WPF app that uses Flash10c.ocx developed on a 32 bit machine.
I'm an ASP.NET developer that has never done Winforms/WPF, but I need to create
Im building a WPF 3.5 desktop app that has a self-hosted WCF service. The
i have a wpf app that is updating date/time in one dispatchertimer, another is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.