Show / Hide Table of Contents

Class FormViewModelBase

Base class for view models that provide form services and data validation.

Inheritance
object
NotifyPropertyChangeBase
NotifyPropertyChanged
ViewModelBase
FormViewModelBase
Implements
INotifyPropertyChangeBase
IRefreshable
INotifyPropertyChanged
INotifyDataErrorInfo
Inherited Members
ViewModelBase.IsBusy
ViewModelBase.Observe<T>(Expression<Func<T>>, Action)
ViewModelBase.Observe(Expression<Func<object>>[], Action)
ViewModelBase.Observe(string, Action)
ViewModelBase.Observe(string[], Action)
ViewModelBase.ObserveFrom<T>(T, Expression<Func<T, object>>, Action)
ViewModelBase.ObserveFrom(INotifyPropertyChanged, PropertyInfo, Action)
ViewModelBase.BusyOp(Action)
ViewModelBase.BusyOp(Task)
ViewModelBase.BusyOp<T>(Func<T>)
ViewModelBase.BusyOp<T>(Task<T>)
NotifyPropertyChanged.PropertyChanged
NotifyPropertyChanged.Notify(params string[])
NotifyPropertyChanged.Notify(string)
NotifyPropertyChanged.RaisePropertyChangeEvent(in string, in PropertyChangeNotificationType)
NotifyPropertyChangeBase.OnInitialize(NotifyPropertyChangeBase.IPropertyBroadcastSetup)
NotifyPropertyChangeBase.Refresh()
NotifyPropertyChangeBase.Subscribe(PropertyInfo, PropertyChangeObserver)
NotifyPropertyChangeBase.Subscribe(PropertyChangeObserver)
NotifyPropertyChangeBase.Subscribe(Expression<Func<object>>, PropertyChangeObserver)
NotifyPropertyChangeBase.Unsubscribe(PropertyChangeObserver)
NotifyPropertyChangeBase.Unsubscribe(PropertyInfo)
NotifyPropertyChangeBase.Unsubscribe(Expression<Func<object>>)
NotifyPropertyChangeBase.Change<T>(ref T, T, string)
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: TheXDS.MCART.Types.Base
Assembly: MCART.Mvvm.dll
Syntax
public abstract class FormViewModelBase : ViewModelBase, INotifyPropertyChangeBase, IRefreshable, INotifyPropertyChanged, INotifyDataErrorInfo

Properties

| Edit this page View Source

ErrorSource

Returns this instance; required for proper INotifyPropertyChanged implementation.

Declaration
public INotifyDataErrorInfo ErrorSource { get; }
Property Value
Type Description
INotifyDataErrorInfo
| Edit this page View Source

HasErrors

Gets a value indicating whether this instance has any validation errors.

Declaration
public bool HasErrors { get; }
Property Value
Type Description
bool

Methods

| Edit this page View Source

CheckErrors()

Runs all validations and returns whether they all passed.

Declaration
public bool CheckErrors()
Returns
Type Description
bool

true if all validations passed and there is at least one rule; otherwise, false.

| Edit this page View Source

GetErrors(string?)

Enumerates the errors for the provided property name, or for all properties if propertyName is null or empty.

Declaration
public IEnumerable GetErrors(string? propertyName)
Parameters
Type Name Description
string propertyName

Name of the property for which to get the errors. If it is an empty string or null, this method returns all validation errors.

Returns
Type Description
IEnumerable

An enumeration of all validation error messages for the specified property or for all properties.

| Edit this page View Source

OnDoChange<T>(ref T, T, string)

Overrides Change<T>(ref T, T, string) to run validations for a property when its value changes.

Declaration
protected override void OnDoChange<T>(ref T backingStore, T value, string propertyName)
Parameters
Type Name Description
T backingStore

Field that holds the property value.

T value

Value to set.

string propertyName

Name of the property. This parameter should normally be omitted (compiler-inferred) unless a different property must be notified.

Type Parameters
Name Description
T

Type of the backing field.

Overrides
NotifyPropertyChanged.OnDoChange<T>(ref T, T, string)
| Edit this page View Source

RegisterValidation<T>(Expression<Func<T>>)

Registers a validation ruleset for a property.

Declaration
protected FormViewModelBase.IValidationEntry<T> RegisterValidation<T>(Expression<Func<T>> propertySelector)
Parameters
Type Name Description
Expression<Func<T>> propertySelector

Expression that selects the property to configure.

Returns
Type Description
FormViewModelBase.IValidationEntry<T>

An object that allows configuring the validation rules to apply to the selected property.

Type Parameters
Name Description
T

Property type.

| Edit this page View Source

ValidationAffects(params SimpleCommand[])

Informs the validation engine which commands are affected by validation failures.

Declaration
protected void ValidationAffects(params SimpleCommand[] commands)
Parameters
Type Name Description
SimpleCommand[] commands

Commands that should be disabled when validation fails.

Remarks

Call this method after instantiating the commands.

Events

| Edit this page View Source

ErrorsChanged

Triggered whenever validations are run.

Declaration
public event EventHandler<DataErrorsChangedEventArgs>? ErrorsChanged
Event Type
Type Description
EventHandler<DataErrorsChangedEventArgs>

Implements

INotifyPropertyChangeBase
IRefreshable
INotifyPropertyChanged
INotifyDataErrorInfo

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)
ObservingCommandBuilder.Create<T>(T, Action)
ObservingCommandBuilder.Create<T>(T, Action<object?>)
ObservingCommandBuilder.Create<T>(T, Func<object?, Task>)
ObservingCommandBuilder.Create<T>(T, Func<Task>)
ObservingCommandBuilder.Create<T, TParam>(T, Action<TParam>)
ObservingCommandBuilder.Create<T, TParam>(T, Func<TParam, Task>)
CollectionExtensions.PushInto<TItem, TCollection>(TItem, ICollection<TCollection>)
DictionaryExtensions.PushInto<TKey, TValue>(TValue, TKey, IDictionary<TKey, TValue>)
NotifyPropertyChangeBaseExtensions.Subscribe<T>(T, Expression<Func<T, object?>>, PropertyChangeObserver)
NotifyPropertyChangeBaseExtensions.Unsubscribe<T>(T, Expression<Func<T, object?>>)
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX