Class Button
A ContentControl that fires Click/executes Command when tapped (see ITouchEvents) and is a tab-stop by default.
public class Button : ContentControl, INotifyPropertyChanging, IBindingTarget, INotifyPropertyChanged, INotifyFocusChanged, IContainerLayout
- Inheritance
-
Button
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
Button()
Initializes a new instance of the Button class.
public Button()
Properties
Command
Gets or sets the command to execute when the button is tapped/activated, in addition to raising Click.
public ICommand? Command { get; set; }
Property Value
CommandParameter
Gets or sets the parameter passed to Command.
public object? CommandParameter { get; set; }
Property Value
Methods
OnActivate()
Invoked by Canvas for an activation press (Enter, gamepad A) while this element or one of its descendants has focus.
protected override bool OnActivate()
Returns
- bool
true to claim the press; Canvas then stops calling further ancestors. The base implementation returns false.
Remarks
Clicks the button, like a tap, unless it's disabled.
OnClick()
protected virtual void OnClick()
OnTap()
Invoked by Canvas when this element (or a descendant) is the target of a completed tap (see Tap). The base implementation does nothing.
protected override void OnTap()
Remarks
Called on the hit-tested element and every one of its ancestors (bubbling, with no "handled" flag in
v1) - so e.g. a Button reacts to a tap on its label TextBlock just as it would to a tap on
its own background.
Events
Click
Occurs when the button is tapped/activated.
public event EventHandler? Click