WPF, resolve the ListBox, press and hold ListBoxItem down to drag the listbox down, and the horizontal scroll bar runs to the end.

Source: Internet
Author: User

A control that resembles this style. , there is such a problem in the case of a horizontal scroll bar hiding. (The horizontal scroll bar will also be displayed, and I don't know how to solve it at the moment.) )

Because this control offset is to take advantage of the width of the StackPanel in the Itemspaneltemplate template of the ListBox by setting "(Uielement.rendertransform). (translatetransform.x) "to offset to the specified position.

So the horizontal scroll bar must be at the front of the movement, or the cheap location will be wrong.

Hold down 4, press and hold the mouse down to move out of the ListBox, and the scroll bar will automatically run to the end.

Workaround

How to disable ListBox auto scroll on mouse down and auto scrollIntoView on item selected?

    public class TListBoxDisableScroll:System.Windows.Controls.ListBox    {        #region fix press and hold item down drag, scroll bar runs to the last        protected override void Onpreviewmousemove (MouseEventArgs e)        {            base. Onpreviewmousemove (e);            E.handled = true;        }        protected override void Onismousecapturedchanged (DependencyPropertyChangedEventArgs e)        {        }        # Endregion    }

Or force a scroll to the first

        private void Scrollviewer_scrollchanged (object sender, System.Windows.Controls.ScrollChangedEventArgs e)        {            Thelistbox.scrollintoview (thelistbox.items[0]);        This is where you add an event handler implementation.        }

  

WPF, resolve the ListBox, press and hold ListBoxItem down to drag the listbox down, and the horizontal scroll bar runs to the end.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.