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)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public int ClickCount { get; }
/** @property */
public int get_ClickCount ()

public function get ClickCount () : int

Members of this class are either not typically used in XAML, or cannot be used in XAML.

Property Value

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";
    }
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft