Can be used for detaching view from the view model in silverlight
namespace Sra.SilverlightUtils {
public interface ICommandNotifier:ICommand {
event EventHandler CommandExecuted;
}
public class DefaultCommandNotifier: ICommandNotifier {
public bool CanExecute(object parameter){
return true;
}
public void Execute(object parameter){
OnCommandExecuted(EventArgs.Empty);
}
private void OnCommandExecuted(EventArgs e){
if( CommandExecuted != null ) {
CommandExecuted(this, e);
}
}
public event EventHandler CanExecuteChanged;
public event EventHandler CommandExecuted;
}
}
ICommandNotifier expands the ICommand interface by adding the CommandExecuted event. The default implementation of this interface doesn't execute any action from within the Execute method. Instead, it will simply fire the CommandExecuted event.
I can reuse this class in several view model instances and, at the same time, customize the code that should be "executed" in each command.
Fork
0 Feedback
You must log in before you can give any feedback
You must log in before you can post a comment


271
0




Mark 'c#' tag as 'like'
Mark 'c#' tag as 'ignore'