Namespace
Inheritance
Control → TemplatedControl → ContentControl → Button
Properties
Gets or sets a value indicating how the button reacts to clicks. Values:
Release (default) or Press.Gets or sets an ICommand to be invoked when the button is clicked.
Gets or sets a parameter to be passed to the Command.
Gets or sets a KeyGesture associated with this control.
Gets or sets a value indicating whether the button is the default button for the window (activated by Enter key).
Gets or sets a value indicating whether the button is the Cancel button for the window (activated by Escape key).
Gets a value indicating whether the button is currently pressed. Read-only.
Gets or sets the Flyout that should be shown with this button.
Events
Raised when the user clicks the button.
Methods
Opens the button’s flyout (if set).
Closes the button’s flyout (if open).
Protected Methods
Invokes the Click event. Override to customize click behavior.
Invoked when the button’s flyout is opened. Override to add custom logic.
Invoked when the button’s flyout is closed. Override to add custom logic.
Usage
XAML Example - Basic Button
XAML Example - Command Binding
XAML Example - Default/Cancel Buttons
XAML Example - With Flyout
C# Example - Event Handler
C# Example - Command Pattern
Hotkey Example
Custom Click Mode
ClickMode Enum
Release
The Click event is raised when the pointer is released (default behavior).
Press
The Click event is raised when the pointer is pressed.
Source File
Button.cs:1-756
See Also
- RepeatButton - Button that repeats clicks
- ToggleButton - Button with checked state
- ICommand - Command interface