Skip to main content
.NET Framework Class Library
ControlMouseDoubleClick Event

Occurs when a mouse button is clicked two or more times.

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Syntax
Public Event MouseDoubleClick As [%$TOPIC/ms597616_en-us_VS_110_1_0_0_0_0%]
public event [%$TOPIC/ms597616_en-us_VS_110_1_0_1_0_0%] MouseDoubleClick
public:
 event [%$TOPIC/ms597616_en-us_VS_110_1_0_2_0_0%]^ MouseDoubleClick {
	void add ([%$TOPIC/ms597616_en-us_VS_110_1_0_2_0_1%]^ value);
	void remove ([%$TOPIC/ms597616_en-us_VS_110_1_0_2_0_2%]^ value);
}
member MouseDoubleClick : IEvent<[%$TOPIC/ms597616_en-us_VS_110_1_0_3_0_0%],
    [%$TOPIC/ms597616_en-us_VS_110_1_0_3_0_1%]>
JScript does not support events.
<object MouseDoubleClick="[%$TOPIC/ms597616_en-us_VS_110_1_0_5_0_0%]" .../>
Routed Event Information

Identifier field

MouseDoubleClickEvent

Routing strategy

Direct

Delegate

MouseButtonEventHandler

Remarks

Although 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. If 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.

Control authors who want to handle mouse double clicks should use the MouseLeftButtonDown event when ClickCount is equal to two. This will cause the state of Handled to propagate appropriately in the case where another element in the element tree handles the event.

The Control class defines the PreviewMouseDoubleClick and MouseDoubleClick events, but not corresponding single-click events. 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.

Examples

The following example shows how to attach an event handler to the MouseDoubleClick event.

<Button Name="btn" Background="Red" 
        MouseDoubleClick="ChangeBackground">
  Background
</Button>

The following example shows the event handler of the MouseDoubleClick event.

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." 

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

End Sub
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.";
    }
    else
    {
        btn.Background = Brushes.Red;
        btn.Content = "Background";
    }
}
Version Information

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1