You can implement methods to match the signature of Action or Action<dynamic>, these will automatically be called from any ICommand bindings in your view.   In the case of Action<dynamic> the command parameter will be passed in.

Another option is to use properties of type Action or Action<dynamic>.  These function the same as methods.

If your ViewModel has no methods, and for performance you want to use properties with Action or Action<dynamic>. Pass this to your base constructor:

class YourViewModel : ViewModel
    public YourViewModel() : base(false) { }

This disables the reflection that hooks up methods to ICommand.

If you want to properly disable controls in your view based on CanExecute(), merely set a CanX property to true or false where X is the name of your action (method or property).

Last edited Aug 4, 2011 at 3:10 AM by jonathanpeppers, version 3


No comments yet.