Show / Hide Table of Contents

Class RelayCommand

Describes a standard RelayCommand implementation commonly used under the MVVM pattern in WPF.

Inheritance
object
RelayCommand
Implements
ICommand
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: TheXDS.MCART.Component
Assembly: MCART.Wpf.Mvvm.dll
Syntax
public class RelayCommand : ICommand

Constructors

| Edit this page View Source

RelayCommand(Action<object?>)

Initializes a new instance of the RelayCommand class.

Declaration
public RelayCommand(Action<object?> action)
Parameters
Type Name Description
Action<object> action

Command to execute.

| Edit this page View Source

RelayCommand(Action<object?>, Func<object?, bool>?)

Describes a standard RelayCommand implementation commonly used under the MVVM pattern in WPF.

Declaration
public RelayCommand(Action<object?> action, Func<object?, bool>? canExecute)
Parameters
Type Name Description
Action<object> action

Command to execute.

Func<object, bool> canExecute

Function that determines whether the command can be executed.

Methods

| Edit this page View Source

CanExecute(object?)

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

Declaration
public bool CanExecute(object? parameter)
Parameters
Type Name Description
object parameter

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

Returns
Type Description
bool

true if the command can execute; otherwise false.

| Edit this page View Source

Execute(object?)

Defines the method to call when the command is invoked.

Declaration
public void Execute(object? parameter)
Parameters
Type Name Description
object parameter

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

| Edit this page View Source

RaiseCanExecuteChanged()

Forces the command to re-evaluate CanExecute(object?).

Declaration
public static void RaiseCanExecuteChanged()

Events

| Edit this page View Source

CanExecuteChanged

Occurs when changes affect whether the command should execute.

Declaration
public event EventHandler? CanExecuteChanged
Event Type
Type Description
EventHandler

Implements

ICommand

Extension Methods

Objects.ShallowCopyTo(object, object, Type)
ObjectExtensions.FieldsOf<T>(object)
ObjectExtensions.GetAttribute<T>(object)
ObjectExtensions.GetAttributes<T>(object)
ObjectExtensions.HasAttrValue<TAttribute, TValue>(object, out TValue)
ObjectExtensions.HasAttribute<T>(object)
ObjectExtensions.HasAttribute<T>(object, out T?)
ObjectExtensions.HasAttributes<T>(object, out IEnumerable<T>?)
ObjectExtensions.Is(object?, object?)
ObjectExtensions.IsEither(object, IEnumerable)
ObjectExtensions.IsEither(object, params object[])
ObjectExtensions.IsNeither(object, IEnumerable)
ObjectExtensions.IsNeither(object, params object[])
ObjectExtensions.IsNot(object?, object?)
ObjectExtensions.PropertiesOf<T>(object)
ObjectExtensions.WhichAre(object, IEnumerable<object>)
ObjectExtensions.WhichAre(object, params object[])
Common.IfNotNull<T>(T?, Action<T>)
Objects.Itself<T>(T)
Objects.ShallowCopyTo<T>(T, T)
CollectionExtensions.PushInto<TItem, TCollection>(TItem, ICollection<TCollection>)
DictionaryExtensions.PushInto<TKey, TValue>(TValue, TKey, IDictionary<TKey, TValue>)
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX