Command for a menu/tool item that can be checked on or off.
Constructors
CheckCommand
#Initializes a new instance of the CheckCommand class with the specified
execute handler.Parameters:
| execute (EventHandler<EventArgs>) | Execute delegate. |
Properties
Bindings
Gets the collection of bindings that are attached to this widget
Checked
#Gets or sets a value indicating whether this command is checked.
Value:
true if checked; otherwise, false.CommandParameter
Gets or sets the parameter to pass to the Command when executing or determining its CanExecute state.
Value: The command parameter.
DataContext
Gets or sets the data context for this widget for binding
Remarks: Subclasses may override the standard behaviour so that hierarchy of widgets can be taken into account. For example, a Control may return the data context of a parent, if it is not set explicitly.
Implements: DataContext
DelegatedCommand
Gets or sets a command to delegate to when the command is invoked.
Remarks: This allows you to use a command to define menu/toolbar items or other functionality, and use a delegated command to chain to when invoked. This is especially useful when binding to a view model, you can do something like the following:
var myCommand = new Command { MenuText = "My Command", Parent = myForm };
myCommand.BindDataContext(c => c.DelegatedCommand, (MyModel m) => m.MyModelCommand);
//...
myForm.DataContext = new MyModel { MyModelCommand = ... }; The ICommand.CanExecute(object) will also used to set the enabled/disabled state of the current command.Value: The command to invoke.
inherited fromCommand
Value:
true if enabled; otherwise, false.Remarks: This can be used to identify a command.
Value: The command ID.
Remarks: On some platforms, the menu bar does not show the image by default (e.g. OS X). You can override this behaviour using a style on the handler.
Value: The image for menu or tool items.
inherited fromCommand
Remarks: This can be used to determine when to allow certain logic during the update of the data context. It is used to disable binding setters on the model when the data context changes so that a binding does not cause the view model to be updated when the state hasn't been fully set yet.
Value:
true if the DataContext is currently changing, false otherwise.Implements: IsDataContextChanging
Parent
Gets the parent widget which this widget has been added to, if any
Value: The parent widget, or null if there is no parent
Value: The command shortcut.
Methods
CreateToolItem
#Creates a new tool item attached to this command.
Returns: The tool item for the command.
Overrides: Command.CreateToolItem
Implements: SetValue
Execute
public void Execute()
Execute the command programatically.
inherited fromCommand
Remarks: Implementors may override this to fire this event on child widgets in a heirarchy. This allows a control to be bound to its own Command.DataContext, which would be set on one of the parent control(s).
Parameters:
| e (EventArgs) | Event arguments |
inherited fromCommand
Parameters:
| e (EventArgs) | Event arguments. |
Parameters:
| e (EventArgs) | Event arguments. |
Events
inherited fromCommand
Remarks: This may be fired in the event of a parent in the hierarchy setting the data context. For example, the Container widget fires this event when it's event is fired.
Implements: DataContextChanged
inherited fromCommand
Executed
Occurs when the command is executed from either the menu or toolbar.