ButtonBase.Click Event
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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;
C#
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
XAML
<button Click="eventhandler"/>
The following example demonstrates handling the Click event and setting the IsEnabled property of a Button, which inherits from ButtonBase.
XAML
<StackPanel>
<Button Content="Submit"
Click="submitButtonClick"/>
<TextBlock x:Name="textBlock1"/>
</StackPanel>
C#
void submitButtonClick(object sender, RoutedEventArgs e)
{
textBlock1.Text = "You clicked the Submit button.";
}
Private Sub submitButtonClick(ByVal sender As Object, ByVal e As RoutedEventArgs)
textBlock1.Text = "You clicked the Submit button."
End Sub
Product | Versions |
---|---|
WinRT | Build 10240, Build 10586, Build 14383, Build 15063, Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100 |