Delta Property
Collapse the table of content
Expand the table of content

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
Available since 3.0
Available since 3.0
Windows Phone Silverlight
Available since 7.0
Return to top
© 2016 Microsoft