This post is simply a PSA for the next person who is trying to get up to speed w/ WPF and cannot figure out why your implementation of CanExecute from ICommand is only being called one time.
When you create your command class which implements ICommand and you let VS (or R#) auto-generate your implementation it will only generate the empty EventHandler for CanExecuteChange. When the empty handler is setup you will not be able to hookup your notification events to allow the ICommand to know to check for CanExecute again.
To resolve this simply hookup the EventHandler as such:
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
After you have setup your handlers correctly your CanExecute logic should start to fire each time the command is updated.
Hope this helps.
Till Next time,
Posted
04-25-2010 12:46 PM
by
Derik Whittaker