ButtonBase.Click Evento

Definizione

Si verifica quando si fa clic su un controllo pulsante.

// 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"/>

Tipo evento

Esempio

Nell'esempio seguente viene illustrata la gestione dell'evento Click e l'impostazione della proprietà IsEnabled di un controllo Button, che eredita da 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.";
}

Commenti

Esiste anche un evento UIElement.Tapped che indica che un elemento è stato premuto e rilasciato con un dispositivo puntatore, ad esempio un mouse o un tocco. Tuttavia, è consigliabile usare questo Click evento come notifica per utilizzo generico che il pulsante è stato fatto clic, perché risponde anche a un pulsante che è stato fatto clic con la tastiera o gli strumenti di accessibilità.

Si applica a

Vedi anche