Click or drag to resize

BindingExecuteCommand Method (Object, IndirectBindingICommand, Object)

Executes a command retrieved using the specified commandBinding from the dataContext.

Namespace:  Eto.Forms
Assembly:  Eto (in Eto.dll) Version: 2.5.3-dev
Syntax
public static void ExecuteCommand(
	Object dataContext,
	IndirectBinding<ICommand> commandBinding,
	Object parameter = null
)

Parameters

dataContext
Type: SystemObject
Data context object to get the ICommand via the commandBinding.
commandBinding
Type: Eto.FormsIndirectBindingICommand
Binding to get the ICommand from the data context
parameter (Optional)
Type: SystemObject
Parameter to pass to the command when executing or checking if it can execute.
Remarks
This helper method is useful for binding general events to fire an ICommand that is in your view model. The command will only be executed if its CanExecute(Object) returns true. Most controls (e.g. Button) have a special Command parameter that can be set instead, which takes into account the enabled state of the command and will enable/disable the control automatically.
Examples
This example will fire the MyModel.MyCommand when the mouse is down on the specified panel. The MyModel instance is based off the panel's current DataContext.
var panel = new Panel();
panel.MouseDown += (sender, e) => Binding.ExecuteCommand(panel.DataContext, Binding.Property((MyModel m) => m.MyCommand));
See Also