2 out of 3 rated this helpful - Rate this topic

ButtonBase.Click Event

April 12, 2014

Occurs when a Button is tapped.

Namespace:  System.Windows.Controls.Primitives
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.
public event RoutedEventHandler Click
<button Click="eventhandler"/>

Instead of using MouseLeftButtonDown or MouseLeftButtonUp, you should use the Click event to detect a button tap by the user. Because of the way that the ButtonBase class handles user tap 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" />


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.