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 }; }
void ThumbDragDelta(object sender, DragDeltaEventArgs e) { Thumb thumb = (Thumb)sender; ScrollBar scrollBar = thumb.GetParent <ScrollBar>(); // Check that we're within the range of the ScrollBar if ((_previewToolTip != null) && (scrollBar.Value > scrollBar.Minimum) && (scrollBar.Value < scrollBar.Maximum)) { // This is a little trick to cause the ToolTip to update its position next to the Thumb if (scrollBar.Orientation == Orientation.Vertical) { _previewToolTip.VerticalOffset = _previewToolTip.VerticalOffset == 0.0 ? 0.001 : 0.0; } else { _previewToolTip.HorizontalOffset = _previewToolTip.HorizontalOffset == 0.0 ? 0.001 : 0.0; } } }