[]
Command binding provides a clean and flexible method for connecting user interface (UI) actions (such as button clicks or menu selections) to the underlying application logic that performs those actions. By binding a control (such as a C1Button) to a command object, developers can encapsulate the action, leading to improved maintainability, simplified testing, and strict adherence to the Model-View-ViewModel (MVVM) design pattern.
Command Property: Accepts an ICommand object. The Execute() method is called automatically when the control is triggered. The control’s enabled state reflects the result of the command’s CanExecute() method to maintain UI and logic consistency.
CommandParameter Property: Passes optional data to the command to enable flexible and context-specific execution.
UI-to-Logic Binding: Connects any C1 control to a command that defines its behavior, allowing you to decouple UI actions from business logic.
Automatic Enable and Disable: Automatically updates the control’s enabled state based on the command’s availability (CanExecute()).
Separation of Concerns: Keeps execution logic in the ViewModel or controller, resulting in a cleaner and more maintainable UI layer.
Reusable and Testable Commands: Allows reuse of commands across multiple controls to improve consistency, reduce duplication, and make commands easier to unit test.
Undo and Redo Support: Provides a foundation for extending commands with undo and redo functionality when needed.