Table of Contents

Class RelayCommand

Namespace
HeBianGu.Base.WpfBase
Assembly
HeBianGu.Base.WpfBase.dll
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

action Action<object>

RelayCommand(Action<object>, Predicate<object>)

public RelayCommand(Action<object> execute, Predicate<object> canExecute)

Parameters

execute Action<object>
canExecute Predicate<object>

Fields

_action

protected Action<object> _action

Field Value

Action<object>

_actionCommand

protected Action<IRelayCommand, object> _actionCommand

Field Value

Action<IRelayCommand, object>

_canExecute

protected readonly Predicate<object> _canExecute

Field Value

Predicate<object>

_canExecuteCommand

protected readonly Func<IRelayCommand, object, bool> _canExecuteCommand

Field Value

Func<IRelayCommand, object, bool>

Properties

IsBusy

public bool IsBusy { get; set; }

Property Value

bool

IsEnabled

public bool IsEnabled { get; set; }

Property Value

bool

IsIndeterminate

说明

public bool IsIndeterminate { get; set; }

Property Value

bool

IsVisible

public bool IsVisible { get; set; }

Property Value

bool

Logger

[Browsable(false)]
public ILogService Logger { get; }

Property Value

ILogService

Message

public string Message { get; set; }

Property Value

string

Name

public string Name { get; set; }

Property Value

string

Percent

public double Percent { get; set; }

Property Value

double

Methods

CanExecute(object)

Defines the method that determines whether the command can execute in its current state.

public bool CanExecute(object parameter)

Parameters

parameter object

Data used by the command. If the command does not require data to be passed, this object can be set to null.

Returns

bool

true if this command can be executed; otherwise, false.

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

EventHandler

PropertyChanged

Occurs when a property value changes.

public event PropertyChangedEventHandler PropertyChanged

Event Type

PropertyChangedEventHandler

Operators

implicit operator RelayCommand(Action<IRelayCommand, object>)

public static implicit operator RelayCommand(Action<IRelayCommand, object> action)

Parameters

action Action<IRelayCommand, object>

Returns

RelayCommand

implicit operator RelayCommand(Action<object>)

public static implicit operator RelayCommand(Action<object> action)

Parameters

action Action<object>

Returns

RelayCommand