XamlUICommand Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides a base class for defining the command behavior of an interactive UI element that performs an action when invoked (such as sending an email, deleting an item, or submitting a form).
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.UI.Xaml.WinUIContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class XamlUICommand : DependencyObject, ICommand
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.WinUIContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public class XamlUICommand : DependencyObject, ICommand
Public Class XamlUICommand
Inherits DependencyObject
Implements ICommand
- Inheritance
- Derived
- Attributes
- Implements
Examples
Tip
For more info, design guidance, and code examples, see Commanding basics.
The WinUI 3 Gallery app includes interactive examples of most WinUI 3 controls, features, and functionality. Get the app from the Microsoft Store or get the source code on GitHub.
Remarks
Implements the ICommand
interface (Microsoft.UI.Xaml.Input.ICommand for C++ or System.Windows.Input.ICommand for C#), adding various UI properties, methods, and events.
XamlUICommand derived classes
XamlUICommand
is the parent class for StandardUICommand, which exposes a set of standard platform commands with pre-defined properties.
For a basic commanding example see the Button control, which is designed to make something happen when a user clicks it.
There are two ways to process a Button
command (controls with a Command
property support similar functionality):
- Handle the
Click
event - Bind the
Command
property to anICommand
implementation that describes the command logic
XamlUICommand
lets you specify UI through the control binding, such as an icon, label, description, and keyboard shortcuts (both an access key and a keyboard accelerator), without setting the individual properties.
Constructors
XamlUICommand() |
Initializes a new instance of the XamlUICommand class. |
Properties
AccessKey |
Gets or sets the access key (mnemonic) for this element. |
AccessKeyProperty |
Identifies the AccessKey dependency property. |
Command |
Gets or sets the command behavior of an interactive UI element that performs an action when invoked, such as sending an email, deleting an item, or submitting a form. |
CommandProperty |
Identifies the Command dependency property. |
Description |
Gets or sets a description for this element. |
DescriptionProperty |
Identifies the Description dependency property. |
Dispatcher |
Always returns |
DispatcherQueue |
Gets the |
IconSource |
Gets or sets a glyph from the Segoe MDL2 Assets font for this element. |
IconSourceProperty |
Identifies the IconSource dependency property. |
KeyboardAccelerators |
Gets the collection of key combinations for this element that invoke an action using the keyboard. |
KeyboardAcceleratorsProperty |
Identifies the KeyboardAccelerators dependency property. |
Label |
Gets or sets the label for this element. |
LabelProperty |
Identifies the Label dependency property. |
Methods
CanExecute(Object) |
Retrieves whether the command can execute in its current state. |
ClearValue(DependencyProperty) |
Clears the local value of a dependency property. (Inherited from DependencyObject) |
Execute(Object) |
Invokes the command. |
GetAnimationBaseValue(DependencyProperty) |
Returns any base value established for a dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject) |
GetValue(DependencyProperty) |
Returns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject) |
NotifyCanExecuteChanged() |
Notifies the system that the command state has changed. |
ReadLocalValue(DependencyProperty) |
Returns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject) |
RegisterPropertyChangedCallback(DependencyProperty, DependencyPropertyChangedCallback) |
Registers a notification function for listening to changes to a specific DependencyProperty on this DependencyObject instance. (Inherited from DependencyObject) |
SetValue(DependencyProperty, Object) |
Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject) |
UnregisterPropertyChangedCallback(DependencyProperty, Int64) |
Cancels a change notification that was previously registered by calling RegisterPropertyChangedCallback. (Inherited from DependencyObject) |
Events
CanExecuteChanged |
Occurs whenever something happens that affects whether the command can execute. |
CanExecuteRequested |
Occurs when a CanExecute call is made. |
ExecuteRequested |
Occurs when an Execute call is made. |