Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Control.PreviewMouseDoubleClick Event

Occurs when a user clicks the mouse button two or more times.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public event MouseButtonEventHandler PreviewMouseDoubleClick
/** @event */
public void add_PreviewMouseDoubleClick (MouseButtonEventHandler value)

/** @event */
public void remove_PreviewMouseDoubleClick (MouseButtonEventHandler value)

In JScript, you can handle the events defined by a class, but you cannot define your own.
<object PreviewMouseDoubleClick="MouseButtonEventHandler" .../>

Identifier Field

PreviewMouseDoubleClickEvent

Routing Strategy

Direct

Delegate

MouseButtonEventHandler

Although this routed event seems to follow a tunneling 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 PreviewMouseDoubleClick event handler, subsequent PreviewMouseDoubleClick events along the route will occur with Handled set to false, but the MouseDoubleClick will occur with Handled set to true. This is a higher-level event for control consumers who want to be notified when the user double-clicks the control and handle in an application.

Control authors who want to handle mouse double clicks should use the PreviewMouseLeftButtonDown 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.

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

<Button Name="btn1" Foreground="Black" 
        PreviewMouseDoubleClick="ChangeForeground">
  Foreground
</Button>

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

void ChangeForeground(object sender, RoutedEventArgs e)
{
    if (btn1.Foreground == Brushes.Green)
    {
        btn1.Foreground = Brushes.Black;
        btn1.Content = "Foreground";
    }
    else
    {
        btn1.Foreground = Brushes.Green;
        btn1.Content = "Control foreground(text) changes from black to green.";
    }
}

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
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft