MouseWheelEventHandler 代理人

定義

代表將處理 MouseWheelMouseWheel 路由事件,以及相關的附加事件和預覽事件的方法。

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)

參數

sender
Object

附加事件處理常式的物件。

e
MouseWheelEventArgs

事件資料。

範例

下列範例會在滑鼠滾輪為正數時向上移動 TextBoxCanvas,如果滑鼠Delta滾輪Delta為負數,則會往上移動 TextBox

// 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

備註

此委派會與下列附加事件搭配使用。

此委派會與下列路由事件搭配使用。 這些路由事件會轉送先前列出的附加事件,使其更容易存取 WPF 中的一般專案模型。

附加事件和基底元素路由事件會共用其事件數據,而路由事件的反升和通道版本也會共用事件數據。 這可能會影響事件在傳送事件路由時所處理的特性。 如需詳細資訊,請參閱 輸入概觀

Delta如果滑鼠滾輪向前移動 (使用者) 或負數,則此屬性為正數;如果滑鼠滾輪向下移動 (使用者) 。

擴充方法

GetMethodInfo(Delegate)

取得表示特定委派所代表之方法的物件。

適用於

另請參閱