Class RelayCommand
public class RelayCommand : ICommand, INotifyPropertyChanged, IRelayCommand
- Inheritance
-
RelayCommand
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
RelayCommand(Action<IRelayCommand, object>)
public RelayCommand(Action<IRelayCommand, object> action)
Parameters
action
Action<IRelayCommand, object>
RelayCommand(Action<IRelayCommand, object>, Func<IRelayCommand, object, bool>)
public RelayCommand(Action<IRelayCommand, object> execute, Func<IRelayCommand, object, bool> canExecute)
Parameters
execute
Action<IRelayCommand, object>canExecute
Func<IRelayCommand, object, bool>
RelayCommand(Action<object>)
public RelayCommand(Action<object> action)
Parameters
RelayCommand(Action<object>, Predicate<object>)
public RelayCommand(Action<object> execute, Predicate<object> canExecute)
Parameters
Fields
_action
protected Action<object> _action
Field Value
_actionCommand
protected Action<IRelayCommand, object> _actionCommand
Field Value
_canExecute
protected readonly Predicate<object> _canExecute
Field Value
_canExecuteCommand
protected readonly Func<IRelayCommand, object, bool> _canExecuteCommand
Field Value
Properties
IsBusy
public bool IsBusy { get; set; }
Property Value
IsEnabled
public bool IsEnabled { get; set; }
Property Value
IsIndeterminate
说明
public bool IsIndeterminate { get; set; }
Property Value
IsVisible
public bool IsVisible { get; set; }
Property Value
Logger
[Browsable(false)]
public ILogService Logger { get; }
Property Value
Message
public string Message { get; set; }
Property Value
Name
public string Name { get; set; }
Property Value
Percent
public double Percent { get; set; }
Property Value
Methods
CanExecute(object)
Defines the method that determines whether the command can execute in its current state.
public bool CanExecute(object parameter)
Parameters
parameter
objectData used by the command. If the command does not require data to be passed, this object can be set to null.
Returns
Execute(object)
执行命令
public virtual void Execute(object parameter)
Parameters
parameter
object
RaisePropertyChanged(string)
public void RaisePropertyChanged(string propertyName = "")
Parameters
propertyName
string
Refresh()
刷新命令可执行状态 (会调用CanExecute方法)
public void Refresh()
Events
CanExecuteChanged
Occurs when changes occur that affect whether or not the command should execute.
public event EventHandler CanExecuteChanged
Event Type
PropertyChanged
Occurs when a property value changes.
public event PropertyChangedEventHandler PropertyChanged
Event Type
Operators
implicit operator RelayCommand(Action<IRelayCommand, object>)
public static implicit operator RelayCommand(Action<IRelayCommand, object> action)
Parameters
action
Action<IRelayCommand, object>
Returns
implicit operator RelayCommand(Action<object>)
public static implicit operator RelayCommand(Action<object> action)