Export (0) Print
Expand All

MouseButtonEventArgs.ClickCount Property

Gets the number of times the button was clicked.

Namespace:  System.Windows.Input
Assembly:  PresentationCore (in PresentationCore.dll)

public int ClickCount { get; internal set; }

Property Value

Type: System.Int32
The number of times the mouse button was clicked.

One use of ClickCount is to determine whether a double mouse click has occurred. Some classes expose events for a double-click, such as the MouseDoubleClick event on the Control class. When a double click event is not exposed on a class, a double click can be detected by using the ClickCount property on the event data.

The following example creates a MouseButtonEventHandler which determines if a single, double, or triple click occurred. ClickCount property is used to determine the number of clicks.

private void OnMouseDownClickCount(object sender, MouseButtonEventArgs e)
{
    // Checks the number of clicks. 
    if (e.ClickCount == 1)
    {
        // Single Click occurred.
        lblClickCount.Content = "Single Click";
    }
    if (e.ClickCount == 2)
    {
        // Double Click occurred.
        lblClickCount.Content = "Double Click";
    }
    if (e.ClickCount >= 3)
    {
        // Triple Click occurred.
        lblClickCount.Content = "Triple Click";
    }
}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft