コード例 #1
0
        void ThumbDragStarted(object sender, DragStartedEventArgs e)
        {
            Thumb     thumb      = (Thumb)sender;
            ScrollBar scrollBar  = thumb.GetParent <ScrollBar>();
            bool      isVertical = scrollBar.Orientation == Orientation.Vertical;

            // Update the content in the ToolTip
            ScrollingPreviewData data = new ScrollingPreviewData();

            data.UpdateScrollingValues(scrollBar);
            data.UpdateItem(AssociatedObject as ItemsControl, isVertical);

            _previewToolTip = new ToolTip
            {
                PlacementTarget  = (UIElement)sender,
                Placement        = isVertical ? PlacementMode.Left : PlacementMode.Top,
                VerticalOffset   = 0.0,
                HorizontalOffset = 0.0,
                ContentTemplate  = (isVertical)
                                        ? VerticalScrollingPreviewTemplate
                                        : HorizontalScrollingPreviewTemplate,
                Content = data,
                IsOpen  = true
            };
        }
コード例 #2
0
        void ScrollBar_Scroll(object sender, ScrollEventArgs e)
        {
            ScrollBar scrollBar = (ScrollBar)sender;

            if (_previewToolTip != null)
            {
                // The ScrollBar's value isn't updated quite yet, so wait until Input priority
                AssociatedObject.Dispatcher.BeginInvoke((Action)(() =>
                {
                    ScrollingPreviewData data = (ScrollingPreviewData)_previewToolTip?.Content;
                    data?.UpdateScrollingValues(scrollBar);
                    data?.UpdateItem(AssociatedObject as ItemsControl, scrollBar.Orientation == Orientation.Vertical);
                }
                                                                 ), DispatcherPriority.Input);
            }
        }
コード例 #3
0
        void ThumbDragStarted(object sender, DragStartedEventArgs e)
        {
            _previewToolTip = new ToolTip();
            ScrollingPreviewData data = new ScrollingPreviewData();

            _previewToolTip.Content = data;

            // Update the content in the ToolTip
            data.UpdateScrollingValues(AssociatedObject);

            // Set the Placement and the PlacementTarget
            _previewToolTip.PlacementTarget = (UIElement)sender;
            _previewToolTip.Placement       = AssociatedObject.Orientation == Orientation.Vertical ? PlacementMode.Left : PlacementMode.Top;

            _previewToolTip.VerticalOffset   = 0.0;
            _previewToolTip.HorizontalOffset = 0.0;

            _previewToolTip.ContentTemplate = ScrollingPreviewTemplate;
            _previewToolTip.IsOpen          = true;
        }