Google News
logo
Xamarin - Interview Questions
What are Commands in Xamarin.Forms?
While writing an application with MVVM, developers specify data bindings in the View Model to bind the UI and the underlying code. Sometimes it may be required that instead of simple properties, the app may have to react to commands initiated by a user that affect something in the View Model.

Such commands are generally associated with button clicks of a button or Tap event of a gesture and are handled by the appropriate background handler. These Commands, that implement the ICommand interface, define the operation to be performed when the appropriate Click or Tap is performed.

To use the command interface, one has to define a data binding that targets the Command Property of the Button whereas the source is a property in the ViewModel of type ICommand.
Advertisement