in Education by
What is Command Design Pattern and ICommand in WPF?

1 Answer

0 votes
by
Command pattern is one of the most powerful design patterns in object oriented design patterns. This pattern allows you to decouple the request of an action from the object that actually performs an action, in other words a command pattern represents an action as an object. A Command object does not contain the functionality that is to be executed. This removes the direct link between the command definitions and the functionality and it’s promoting a loose coupling. When you want to implement operations based on the user request then the command pattern is the best pattern to handle your object.
 
The following are the members of the Command Design Pattern:
  • Client
  • Invoker
  • Command
  • Concrete Command
  • Receiver
Flow of Command Design Pattern
 
Command Design Pattern 
 
ICommand
 
An ICommand is a core component of MVVM. ICommand is frequently used in MVVM, it provides separation logic between a View and View Model (User Interface and Business Logic). XAML offers a way to bind your GUI event better by ICommand. ICommand requires the user to define two methods, bool CanExecute and void Execute. The CanExecute method really just says to the user, can I execute this Action? This is useful for controlling the context in which you can perform GUI actions.
 
ICommand is very simple but it’s more interesting and complicated when you are using it in an application. ICommand integrates your User Interface to business logic or it’s making a direct communication between a View to a View Model. It also provides a mechanism for the view to update the model/view-model.
 
ICommand 
 

Related questions

0 votes
    What is WPF Dependency Property and how can we use?...
asked Apr 9, 2021 in Education by JackTerrance
0 votes
    What is Trigger and how many types of triggers in WPF?...
asked Apr 8, 2021 in Education by JackTerrance
0 votes
    What is the Data Binding concept and How Binding works in WPF?...
asked Apr 8, 2021 in Education by JackTerrance
0 votes
    What is a WPF Child Window?...
asked Apr 9, 2021 in Education by JackTerrance
0 votes
0 votes
0 votes
    What are the various layout panels in WPF ?...
asked Apr 9, 2021 in Education by JackTerrance
...