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 
<button Click="eventhandler"/>

Event Type

Examples

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

<StackPanel>   
    <Button Content="Submit" 
            Click="submitButtonClick"/>
    <TextBlock x:Name="textBlock1"/>
</StackPanel>
void submitButtonClick(object sender, RoutedEventArgs e)
{
    textBlock1.Text = "You clicked the Submit button.";
}

Applies to

See also