Unplanned
Last Updated: 25 Nov 2025 14:18 by Martin Ivanov
Martin Ivanov
Created on: 25 Nov 2025 14:18
Category: Chat
Type: Bug Report
0
Chat: Scrolling with the mouse wheel scrolls directly to the bottom of the messages instead of scrolling smoothly between the items

Scrolling with the mouse wheel scrolls directly to the bottom of the messages instead of scrolling smoothly between the items.

To work this around, create a custom class that derives from RadChat and override its OnPointerWheelChanged method.

public class CustomChat : RadChat
{
    private ScrollViewer scrollViewer;

    internal ScrollViewer ScrollViewer
    {
        get
        {
            if (this.scrollViewer == null)
            {
                this.scrollViewer = this.ChildrenOfType<ScrollViewer>().Where(sc => sc.Name == "PART_ScrollViewer").FirstOrDefault();
            }

            return this.scrollViewer;
        }
    }

    protected override void OnPointerWheelChanged(PointerRoutedEventArgs e)
    {
        if (this.ScrollViewer != null)
        {
            int delta = e.GetCurrentPoint(this).Properties.MouseWheelDelta;
            double wheelDetents = delta / 120.0;
            double scrollableRange = ScrollViewer.ExtentHeight - ScrollViewer.ViewportHeight;                
            double step = 0.01 * scrollableRange;
            double offsetDelta = wheelDetents * step;
            double newOffset = ScrollViewer.VerticalOffset - offsetDelta;
            newOffset = Math.Max(0, Math.Min(ScrollViewer.ExtentHeight, newOffset));

            ScrollViewer.ScrollToVerticalOffset(newOffset);
        }
    }
}

0 comments