.NET Framework Class Library for Silverlight
ButtonBase..::.Click Event

Occurs when a Button is clicked.

Namespace:  System.Windows.Controls.Primitives
Assembly:  System.Windows (in System.Windows.dll)
Syntax

Visual Basic (Declaration)
Public Event Click As RoutedEventHandler
Visual Basic (Usage)
Dim instance As ButtonBase
Dim handler As RoutedEventHandler

AddHandler instance.Click, handler
C#
public event RoutedEventHandler Click
XAML Attribute Usage
<button Click="eventhandler"/>
Remarks

Instead of using MouseLeftButtonDown or MouseLeftButtonUp, you should use the Click event to detect a button click by the user. Because of the way that the ButtonBase class handles mouse events, MouseLeftButtonDown and MouseLeftButtonUp events do not occur when the click mode is a value other than Hover.

Examples

The following example demonstrates handling the Click event of a Button and setting its IsEnabled property.

Visual Basic
Private Sub disableButtonClick(ByVal sender As Object, ByVal e As RoutedEventArgs)
    disableButton.IsEnabled = False
End Sub
C#
void disableButtonClick(object sender, RoutedEventArgs e)
{
    disableButton.IsEnabled = false;
}
XAML
        <Button x:Name="disableButton" Width="200"
        Click="disableButtonClick" Content="Disabled when clicked" />
Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference

Tags :


Page view tracker