Question: OK. Here's the scenario. This is WPF + MVVM (.net 4.0) application:

1. View: Has a `DataGrid` and two buttons Move Up / Move Down, which are supposed to move selected record up or down in the `DataGrid`. Both the grid and the buttons use XAML-based binding.
2. ViewModel: Has a public property of `DataView` type to which my `DataGrid` will bind. Then there are two `ICommand` implementations listed below. The two buttons will bind to these two commands. Last but not the least there are two functions called `MoveUp()` and `MoveDown()` that do the obvious.
3. Two `ICommand` implementations: In each command, `CanExecute()` returns whether selected record can be moved up or down respectively, and `Execute()` actually moves the record by calling ViewModel's `MoveUp()` and `MoveDown()` functions I described above. These command objects get a reference of VM object in their constructors.

First off, I want to know if this architecture correct and in line with MVVM pattern? Secondly, the problem at hand is that my buttons do not get enabled/disabled when I change selected record in the `DataGrid`, which brings up 2 sub-questions:

1. Who calls `CanExecute()` and when?
2. How can I call it manually? I have tried `CommandManager.InvalidateRequerySuggested()` after reading some other SO questions, but that didn't help either.

Here's my `CommandBase` class, from which both my Command classes inherit:

```
internal abstract class CommandBase : DependencyObject, ICommand
{
    public virtual bool CanExecute(Object parameter)
    {
        return true;
    }

    public abstract void Execute(Object parameter);
    public event EventHandler CanExecuteChanged;

    protected void OnCanExecuteChanged(Object sender, EventArgs e)
    {
        CanExecuteChanged(sender, e);
    }
}

```

Answer: 
Replace your 'OnExcuteChanged' with this...

```
public event EventHandler CanExecuteChanged
{
    add
    {
        CommandManager.RequerySuggested += value;
    }
    remove
    {
        CommandManager.RequerySuggested -= value;
    }
}

```
I personally always use the implementation `RelayCommand` from Josh Smith:

```
internal class RelayCommand : ICommand
{
    private readonly Action<object> _execute;
    private readonly Predicate<object> _canExecute;

    public RelayCommand(Action<object> execute) : this(execute, null)
    {
    }

    public RelayCommand(Action<object> execute, Predicate<object> canExecute)
    {
        if (execute == null)
        {
            throw new ArgumentNullException("execute");
        }

        _execute = execute;
        _canExecute = canExecute;
    }

    public bool CanExecute(object parameter)
    {
        return _canExecute == null ? true : _canExecute(parameter);
    }

    public event EventHandler CanExecuteChanged
    {
        add
        {
            CommandManager.RequerySuggested += value;
        }

        remove
        {
            CommandManager.RequerySuggested -= value;
        }
    }

    public void Execute(object parameter)
    {
        _execute(parameter);
    }
}

```

Quote about `CanExecutedChanged` event from this [link](http://msdn.microsoft.com/en-us/magazine/dd419663.aspx):

> 
> The CanExecuteChanged event, which is part of the ICommand interface implementation, has some interesting features. It delegates the event subscription to the CommandManager.RequerySuggested event. This ensures that the WPF commanding infrastructure asks all RelayCommand objects if they can execute whenever it asks the built-in commands.
> 
> 
> 

In your case, this event did not work, and the object has not received information about the possibility of executing the command.