コード例 #1
0
        private void Register()
        {
            itemsPresenter = listBox.FindVisualChildOfType <ItemsPresenter>();

            if (itemsPresenter == null)
            {
                return;
            }

            var adornerLayer = AdornerLayer.GetAdornerLayer(itemsPresenter);

            if (adornerLayer == null)
            {
                return;
            }

            selectionRect = new SelectionAdorner(itemsPresenter);
            adornerLayer.Add(selectionRect);

            selector = new ItemsControlSelector(listBox);

            autoScroller = new AutoScroller(listBox);
            autoScroller.OffsetChanged += OnOffsetChanged;

            // The ListBox intercepts the regular MouseLeftButtonDown event
            // to do its selection processing, so we need to handle the
            // PreviewMouseLeftButtonDown. The scroll content won't receive
            // the message if we click on a blank area so use the ListBox.
            listBox.PreviewMouseLeftButtonDown += OnPreviewMouseLeftButtonDown;
            listBox.MouseLeftButtonUp          += OnMouseLeftButtonUp;
            listBox.MouseMove += OnMouseMove;
        }
コード例 #2
0
        private bool Register()
        {
            this.scrollContent = FindChild <ScrollContentPresenter>(this.listBox);
            if (this.scrollContent != null)
            {
                this.autoScroller = new AutoScroller(this.listBox);
                this.autoScroller.OffsetChanged += this.OnOffsetChanged;

                this.selectionRect = new SelectionAdorner(this.scrollContent);
                this.scrollContent.AdornerLayer.Add(this.selectionRect);

                this.selector = new ItemsControlSelector(this.listBox);

                // The ListBox intercepts the regular MouseLeftButtonDown event
                // to do its selection processing, so we need to handle the
                // PreviewMouseLeftButtonDown. The scroll content won't receive
                // the message if we click on a blank area so use the ListBox.
                this.listBox.PreviewMouseLeftButtonDown += this.OnPreviewMouseLeftButtonDown;
                this.listBox.MouseLeftButtonUp          += this.OnMouseLeftButtonUp;
                this.listBox.MouseMove += this.OnMouseMove;
            }

            // Return success if we found the ScrollContentPresenter
            return(this.scrollContent != null);
        }
コード例 #3
0
 private bool Register()
 {
     UpdateScrollContent();
     if (scrollContent != null)
     {
         autoScroller = new AutoScroller(listBox);
         autoScroller.OffsetChanged += OnOffsetChanged;
         selector = new ItemsControlSelector(listBox);
         // The ListBox intercepts the regular MouseLeftButtonDown event
         // to do its selection processing, so we need to handle the
         // PreviewMouseLeftButtonDown. The scroll content won't receive
         // the message if we click on a blank area so use the ListBox.
         listBox.PreviewMouseLeftButtonDown += OnPreviewMouseLeftButtonDown;
         listBox.MouseLeftButtonUp          += OnMouseLeftButtonUp;
         listBox.MouseMove += OnMouseMove;
     }
     // Return success if we found the ScrollContentPresenter
     return(scrollContent != null);
 }