/************************************************************************/

        #region Constructor (private)
        private RelayCommand(Action <object> execute, Predicate <object> canExecute, CommandSupported supported, object parameter)
        {
            this.execute    = execute ?? throw new ArgumentNullException(nameof(execute));
            this.canExecute = canExecute;
            Supported       = supported;
            Parameter       = parameter;
        }
 /// <summary>
 /// Creates and returns an instance of <see cref="RelayCommand"/>.
 /// </summary>
 /// <param name="execute">The method that executes the command</param>
 /// <param name="canExecute">The method that checks if this command can execute. If null, no check is performed.</param>
 /// <param name="supported">A value that determines if the command is supported.</param>
 /// <returns>A <see cref="RelayCommand"/> object.</returns>
 public static RelayCommand Create(Action <object> execute, Predicate <object> canExecute, CommandSupported supported)
 {
     return(new RelayCommand(execute, canExecute, supported, null));
 }
Esempio n. 3
0
 /// <summary>
 /// Adds a command to the dictionary.
 /// </summary>
 /// <param name="key">The command key.</param>
 /// <param name="runCommand">The action to run the command.</param>
 /// <param name="canRunCommand">The predicate to determine if the command can run, or null if it can always run.</param>
 /// <param name="supported">A value that determines if the command is supported.</param>
 /// <param name="parameter">An optional parameter that if set will always be passed to the command method.</param>
 public void Add(T key, Action <object> runCommand, Predicate <object> canRunCommand, CommandSupported supported, object parameter)
 {
     Add(key, RelayCommand.Create(runCommand, canRunCommand, supported, parameter));
 }