MouseWheelEventHandler Delegado

Definición

Representa el método que controlará los eventos enrutados MouseWheel y MouseWheel, así como los eventos adjuntos y los eventos de vista previa relacionados.Represents the method that will handle the MouseWheel and MouseWheel routed events, as well as related attached and Preview events.

public delegate void MouseWheelEventHandler(System::Object ^ sender, MouseWheelEventArgs ^ e);
public delegate void MouseWheelEventHandler(object sender, MouseWheelEventArgs e);
type MouseWheelEventHandler = delegate of obj * MouseWheelEventArgs -> unit
Public Delegate Sub MouseWheelEventHandler(sender As Object, e As MouseWheelEventArgs)

Parámetros

sender
Object

Objeto en que está asociado el controlador de eventos.The object where the event handler is attached.

e
MouseWheelEventArgs

Datos del evento.The event data.

Herencia
MouseWheelEventHandler

Ejemplos

En el ejemplo siguiente se TextBoxmueve un, que está asociado Canvasa un, hacia arriba si Delta la rueda del mouse es TextBox positiva y se mueve hacia Delta abajo si la rueda del mouse es negativa.The following example moves a TextBox, which is attached to a Canvas, upward if the mouse wheel Delta is positive and moves the TextBox downward if the mouse wheel Delta is negative.

// 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);
        }
    }

}
' Moves the TextBox named box when the mouse wheel is rotated.
' The TextBox is on a Canvas named MainCanvas.
Private Sub MouseWheelHandler(ByVal sender As Object, ByVal e As MouseWheelEventArgs)
    ' If the mouse wheel delta is positive, move the box up.
    If e.Delta > 0 Then
        If Canvas.GetTop(box) >= 1 Then
            Canvas.SetTop(box, Canvas.GetTop(box) - 1)
        End If
    End If

    ' If the mouse wheel delta is negative, move the box down.
    If e.Delta < 0 Then
        If (Canvas.GetTop(box) + box.Height) <= MainCanvas.Height Then
            Canvas.SetTop(box, Canvas.GetTop(box) + 1)
        End If
    End If

End Sub

Comentarios

Este delegado se utiliza con los siguientes eventos adjuntos.This delegate is used with the following attached events.

Este delegado se utiliza con los siguientes eventos enrutados.This delegate is used with the following routed events. Estos eventos enrutados reenvían los eventos adjuntos enumerados anteriormente para que sean más accesibles WPFWPFal modelo de elemento general en.These routed events forward the previously listed attached events to make them more accessible to the general element model in WPFWPF.

Los eventos adjuntos y los eventos enrutados del elemento base comparten sus datos de evento, y las versiones de propagación y tunelización de los eventos enrutados también comparten datos de eventos.The attached events and the base element routed events share their event data, and the bubbling and tunneling versions of the routed events also share event data. Esto puede afectar a las características controladas del evento cuando recorre la ruta del evento.This can affect the handled characteristics of the event as it travels the event route. Para obtener más información, consulte Introducción a la entrada.For details, see Input Overview.

La Delta propiedad es positiva si la rueda del mouse se mueve hacia delante (alejándose del usuario) o negativo si la rueda del mouse se mueve hacia abajo (hacia el usuario).The Delta property is positive if the mouse wheel is moved forward (away from the user) or negative if the mouse wheel is moved downward (toward the user).

Métodos de extensión

GetMethodInfo(Delegate)

Obtiene un objeto que representa el método representado por el delegado especificado.Gets an object that represents the method represented by the specified delegate.

Se aplica a

Consulte también: