Occurs when a Button is clicked.
Assembly: PresentationFramework (in PresentationFramework.dll)
The user can raise the AccessText or by pressing ENTER or the SPACEBAR when the control has focus. When the user presses the SPACEBAR, the control sets IsPressed to true and captures the mouse. As a result, the control will raise mouse events such as MouseEnter and IsMouseDirectlyOverChanged. Note that using the AccessText or ENTER does not change IsPressed or capture the mouse, but it does raise the event.event by using an
The ButtonBase marks the MouseLeftButtonDown event as handled in the OnMouseLeftButtonDown method and raises the event. Hence, the OnMouseLeftButtonDown event will never occur for a control that inherits from ButtonBase. Instead, attach an event handler to the PreviewMouseLeftButtonDown event, or call AddHandler(RoutedEvent, Delegate, Boolean) with handledEventsToo set to true.
The following example shows three buttons that respond to clicks in three different ways.
Hover - the first button changes colors when the user hovers with the mouse over the button
Press - the second button requires that the mouse be pressed while the mouse pointer is in the button.
Release - the third does not reset the background color of the buttons until the mouse is pressed and released in the button.
<Button Name="btn1" Background="Pink" BorderBrush="Black" BorderThickness="1" Click="OnClick1" ClickMode="Hover"> ClickMe1 </Button> <Button Name="btn2" Background="LightBlue" BorderBrush="Black" BorderThickness="1" Click="OnClick2" ClickMode="Press"> ClickMe2 </Button> <Button Name="btn3" Click="OnClick3" ClickMode="Release"> Reset </Button>
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0