Show / Hide Table of Contents

Class ObservingCommand

Describes a command that observes an object implementing INotifyPropertyChanged and listens for any changes to its property values to automatically enable or disable command execution.

Inheritance
object
CommandBase
ObservingCommand
Implements
ICommand
Inherited Members
CommandBase.CanExecuteChanged
CommandBase.CanExecute()
CommandBase.Execute(object)
CommandBase.Execute()
CommandBase.TryExecute(object)
CommandBase.TryExecute()
CommandBase.RaiseCanExecuteChanged()
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.Mvvm.dll
Syntax
public class ObservingCommand : CommandBase, ICommand

Constructors

| Edit this page View Source

ObservingCommand(INotifyPropertyChanged, Action)

Initializes a new instance of ObservingCommand.

Declaration
public ObservingCommand(INotifyPropertyChanged observedSource, Action action)
Parameters
Type Name Description
INotifyPropertyChanged observedSource

The data source to observe.

Action action

The action to execute.

| Edit this page View Source

ObservingCommand(INotifyPropertyChanged, Action<object?>)

Describes a command that observes an object implementing INotifyPropertyChanged and listens for any changes to its property values to automatically enable or disable command execution.

Declaration
public ObservingCommand(INotifyPropertyChanged observedSource, Action<object?> action)
Parameters
Type Name Description
INotifyPropertyChanged observedSource

The data source to observe.

Action<object> action

The action to execute.

| Edit this page View Source

ObservingCommand(INotifyPropertyChanged, Func<object?, Task>)

Initializes a new instance of ObservingCommand.

Declaration
public ObservingCommand(INotifyPropertyChanged observedSource, Func<object?, Task> task)
Parameters
Type Name Description
INotifyPropertyChanged observedSource

The data source to observe.

Func<object, Task> task

The asynchronous task to execute.

| Edit this page View Source

ObservingCommand(INotifyPropertyChanged, Func<Task>)

Initializes a new instance of ObservingCommand.

Declaration
public ObservingCommand(INotifyPropertyChanged observedSource, Func<Task> task)
Parameters
Type Name Description
INotifyPropertyChanged observedSource

The data source to observe.

Func<Task> task

The asynchronous task to execute.

Properties

| Edit this page View Source

ObservedProperties

Enumerates the property names being observed by this ObservingCommand.

Declaration
public IEnumerable<string> ObservedProperties { get; }
Property Value
Type Description
IEnumerable<string>
| Edit this page View Source

ObservedSource

Reference to the data source observed by this ObservingCommand.

Declaration
public INotifyPropertyChanged ObservedSource { get; }
Property Value
Type Description
INotifyPropertyChanged

Methods

| Edit this page View Source

CanExecute(object?)

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

Declaration
public override 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 this command can execute; otherwise, false.

Overrides
CommandBase.CanExecute(object?)
| Edit this page View Source

RegisterObservedProperty(Expression<Func<object?>>)

Registers a property to observe for this command using a lambda expression that selects the property.

Declaration
public ObservingCommand RegisterObservedProperty(Expression<Func<object?>> property)
Parameters
Type Name Description
Expression<Func<object>> property

Expression selecting the property to observe.

Returns
Type Description
ObservingCommand

This same instance, allowing fluent call chaining.

| Edit this page View Source

RegisterObservedProperty(params string[])

Registers one or more property names to observe for this command.

Declaration
public ObservingCommand RegisterObservedProperty(params string[] properties)
Parameters
Type Name Description
string[] properties

The name(s) of the property(ies) to observe.

Returns
Type Description
ObservingCommand

This same instance to allow fluent usage.

| Edit this page View Source

SetCanExecute(Func<bool>)

Sets the check function used to determine whether the command can execute.

Declaration
public ObservingCommand SetCanExecute(Func<bool> canExecute)
Parameters
Type Name Description
Func<bool> canExecute

Function used to determine whether the command can execute.

Returns
Type Description
ObservingCommand

This same instance, allowing fluent call chaining.

| Edit this page View Source

SetCanExecute(Func<INotifyPropertyChanged, object?, bool>?)

Sets the check function used to determine whether the command can execute.

Declaration
public ObservingCommand SetCanExecute(Func<INotifyPropertyChanged, object?, bool>? canExecute)
Parameters
Type Name Description
Func<INotifyPropertyChanged, object, bool> canExecute

Function that receives the observed source and the command parameter and returns whether the command can execute. Pass null to remove the check.

Returns
Type Description
ObservingCommand

This same instance, allowing fluent call chaining.

| Edit this page View Source

SetCanExecute(Func<object?, bool>)

Sets the check function used to determine whether the command can execute.

Declaration
public ObservingCommand SetCanExecute(Func<object?, bool> canExecute)
Parameters
Type Name Description
Func<object, bool> canExecute

Function that receives the command parameter and returns whether the command can execute.

Returns
Type Description
ObservingCommand

This same instance, allowing fluent call chaining.

| Edit this page View Source

UnsetCanExecute()

Disconnects the check function used to determine whether the command can execute.

Declaration
public void UnsetCanExecute()

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>)
ObservingCommandExtensions.CanExecuteIfNotDefault(ObservingCommand, params Expression<Func<ValueType>>[])
ObservingCommandExtensions.CanExecuteIfNotDefault<T>(ObservingCommand, params Expression<Func<T, ValueType>>[])
ObservingCommandExtensions.CanExecuteIfNotNull(ObservingCommand, params Expression<Func<object?>>[])
ObservingCommandExtensions.CanExecuteIfNotNull<T>(ObservingCommand, params Expression<Func<T, object?>>[])
ObservingCommandExtensions.ListensToCanExecute(ObservingCommand, Expression<Func<bool>>)
ObservingCommandExtensions.ListensToCanExecute<T>(ObservingCommand, Expression<Func<T, bool>>)
ObservingCommandExtensions.ListensToProperties(ObservingCommand, params Expression<Func<object?>>[])
ObservingCommandExtensions.ListensToProperties<TProperty>(ObservingCommand, params Expression<Func<TProperty>>[])
ObservingCommandExtensions.ListensToProperties<T>(ObservingCommand, params Expression<Func<T, object?>>[])
ObservingCommandExtensions.ListensToProperties<T, TProperty>(ObservingCommand, params Expression<Func<T, TProperty>>[])
ObservingCommandExtensions.ListensToProperty(ObservingCommand, Expression<Func<object?>>)
ObservingCommandExtensions.ListensToProperty<T>(ObservingCommand, Expression<Func<T, object?>>)
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX