This documentation is archived and is not being maintained.

MouseWheelEventArgs.Delta Property

Gets a value that indicates the amount that the mouse wheel has changed.

Namespace:  System.Windows.Input
Assembly:  PresentationCore (in PresentationCore.dll)

public int Delta { get; }

Property Value

Type: System.Int32
The amount the wheel has changed. This value is positive if the mouse wheel is rotated in an upward direction (away from the user) or negative if the mouse wheel is rotated in a downward direction (toward the user).

The effective upper and lower ranges of this value potentially come from device implementations or other callers that raised the event, and are therefore not defined.

The following example moves a TextBox up if the mouse wheel Delta is positive and moves the TextBox down if the mouse wheel Delta is negative. The TextBox is attached to a Canvas.


// Moves the TextBox named box when the mouse wheel is rotated.
// The TextBox is on a Canvas named MainCanvas.
private void MouseWheelHandler(object sender, MouseWheelEventArgs e)
{
    // If the mouse wheel delta is positive, move the box up.
    if (e.Delta > 0)
    {
        if (Canvas.GetTop(box) >= 1)
        {
            Canvas.SetTop(box, Canvas.GetTop(box) - 1);
        }
    }

    // If the mouse wheel delta is negative, move the box down.
    if (e.Delta < 0)
    {
        if ((Canvas.GetTop(box) + box.Height) <= (MainCanvas.Height))
        {
            Canvas.SetTop(box, Canvas.GetTop(box) + 1);
        }
    }

}


.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: