Control.MouseDoubleClick Control.MouseDoubleClick Control.MouseDoubleClick Control.MouseDoubleClick Event


發生於按兩下或更多下滑鼠按鈕時。Occurs when a mouse button is clicked two or more times.

 event System::Windows::Input::MouseButtonEventHandler ^ MouseDoubleClick;
public event System.Windows.Input.MouseButtonEventHandler MouseDoubleClick;
member this.MouseDoubleClick : System.Windows.Input.MouseButtonEventHandler 
Public Custom Event MouseDoubleClick As MouseButtonEventHandler 


下列範例示範如何附加至事件處理常式MouseDoubleClick事件。The following example shows how to attach an event handler to the MouseDoubleClick event.

<Button Name="btn" Background="Red" 

下列範例顯示的事件處理常式MouseDoubleClick事件。The following example shows the event handler of the MouseDoubleClick event.

void ChangeBackground(object sender, RoutedEventArgs e)
    if (btn.Background == Brushes.Red)
        btn.Background = new LinearGradientBrush(Colors.LightBlue, Colors.SlateBlue, 90);
        btn.Content = "Control background changes from red to a blue gradient.";
        btn.Background = Brushes.Red;
        btn.Content = "Background";
Private Sub ChangeBackground(ByVal Sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)

    If (btn.Background Is Brushes.Red) Then

        btn.Background = New LinearGradientBrush(Colors.LightBlue, Colors.SlateBlue, 90)
        btn.Content = "Control background changes from red to a blue gradient."

        btn.Background = Brushes.Red
        btn.Content = "Background"
    End If

End Sub


雖然此路由的事件似乎會遵循事件反昇路由項目樹狀結構,實際上是由每個引發沿著項目樹狀結構的直接路由的事件UIElementAlthough this routed event seems to follow a bubbling route through an element tree, it actually is a direct routed event that is raised along the element tree by each UIElement. 如果您設定Handled屬性,以trueMouseDoubleClick事件處理常式,後續MouseDoubleClick路由事件會發生Handled設為falseIf you set the Handled property to true in a MouseDoubleClick event handler, subsequent MouseDoubleClick events along the route will occur with Handled set to false. 這是較高層級的事件的控制項的取用者想要在使用者按兩下控制項時收到通知,並處理應用程式中的事件。This is a higher-level event for control consumers who want to be notified when the user double-clicks the control and to handle the event in an application.

應該使用的控制項作者想要處理滑鼠點按動作雙MouseLeftButtonDown事件時ClickCount等於兩個。Control authors who want to handle mouse double clicks should use the MouseLeftButtonDown event when ClickCount is equal to two. 這會導致狀態Handled中的項目樹狀結構中的另一個項目會處理事件的情況適當地傳播。This will cause the state of Handled to propagate appropriately in the case where another element in the element tree handles the event.

Control類別會定義PreviewMouseDoubleClickMouseDoubleClick事件,但未對應的按一下事件。The Control class defines the PreviewMouseDoubleClick and MouseDoubleClick events, but not corresponding single-click events. 若要查看是否使用者按一下控制項一次,處理MouseDown事件 (或其對應項目),並檢查是否ClickCount屬性值為 1。To see if the user has clicked the control once, handle the MouseDown event (or one of its counterparts) and check whether the ClickCount property value is 1.

路由事件資訊Routed Event Information

識別項欄位Identifier field MouseDoubleClickEvent
路由策略Routing strategy 直接Direct
Delegate - 委派Delegate MouseButtonEventHandler