Export (0) Print
Expand All

ButtonBase.Click Event

Occurs when a Button is clicked.

Namespace:  System.Windows.Controls.Primitives
Assembly:  System.Windows (in System.Windows.dll)

public event RoutedEventHandler Click
<button Click="eventhandler"/>

Instead of using MouseLeftButtonDown or MouseLeftButtonUp, you should use the Click event to detect a button click by the user. Because of the way that the ButtonBase class handles mouse events, MouseLeftButtonDown and MouseLeftButtonUp events do not occur when the click mode is a value other than Hover.

The following example demonstrates handling the Click event of a Button and setting its IsEnabled property.


void disableButtonClick(object sender, RoutedEventArgs e)
{
    disableButton.IsEnabled = false;
}



        <Button x:Name="disableButton" Width="200"
		Click="disableButtonClick" Content="Disabled when clicked" />


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

Show:
© 2014 Microsoft