Language

ButtonBase.Click Event

Definition

Occurs when a button control is clicked.

// Register
event_token Click(RoutedEventHandler const& handler) const;

// Revoke with event_token
void Click(event_token const* cookie) const;

// Revoke with event_revoker
ButtonBase::Click_revoker Click(auto_revoke_t, RoutedEventHandler const& handler) const;
public event RoutedEventHandler Click;
function onClick(eventArgs) { /* Your code */ }
buttonBase.addEventListener("click", onClick);
buttonBase.removeEventListener("click", onClick);
- or -
buttonBase.onclick = onClick;
Public Custom Event Click As RoutedEventHandler 

Event Type

Examples

The following example demonstrates handling the Click event and setting the IsEnabled property of a Button, which inherits from ButtonBase.

   
    
void submitButtonClick(object sender, RoutedEventArgs e)
{
    textBlock1.Text = "You clicked the Submit button.";
}

Remarks

There is also a UIElement.Tapped event that indicates that an element has been pressed and released with a pointer device, such as a mouse or touch. However, we recommend that you use this Click event as a general purpose notification that the button has been clicked, because it also responds to a button having been clicked with the keyboard or accessibility tools.

Applies to

See also