Class FormViewModelBase
Clase base que permite definir un ViewModel que provee de servicios de formulario y validación de datos.
Inherited Members
Namespace: TheXDS.MCART.Types.Base
Assembly: MCART.Mvvm.dll
Syntax
public abstract class FormViewModelBase : ViewModelBase, INotifyPropertyChangeBase, IRefreshable, INotifyPropertyChanged, INotifyDataErrorInfo
Properties
| Edit this page View SourceErrorSource
Returns this instance, required for proper INotifyPropertyChanged implementation.
Declaration
public INotifyDataErrorInfo ErrorSource { get; }
Property Value
Type | Description |
---|---|
INotifyDataErrorInfo |
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 SourceCheckErrors()
Checks for validation errors.
Declaration
public bool CheckErrors()
Returns
Type | Description |
---|---|
bool |
GetErrors(string?)
Enumerates the errors for the provided property name, or for all
properties if propertyName
is
null.
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 will return all validation errors. |
Returns
Type | Description |
---|---|
IEnumerable | An enumeration of all validation errors for the specified property or for all properties. |
OnDoChange<T>(ref T, T, string)
Reemplaza el método Change<T>(ref T, T, string), permitiendo la ejecución de validaciones sobre una propiedad.
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 be set. |
string | propertyName | Name of the property. This parameter should be omitted always, unless you need to specify a different property to be notified. |
Type Parameters
Name | Description |
---|---|
T | Type of backing field. |
Overrides
| Edit this page View SourceRegisterValidation<T>(Expression<Func<T>>)
Registers a property validation ruleset.
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 be configured. |
Returns
Type | Description |
---|---|
FormViewModelBase.IValidationEntry<T> | An object which allows the configuration of the validation rules to be applied to the selected property. |
Type Parameters
Name | Description |
---|---|
T | Property type. |
ValidationAffects(params SimpleCommand[])
Tells to the validation engine that validation will affect the specified commands.
Declaration
protected void ValidationAffects(params SimpleCommand[] commands)
Parameters
Type | Name | Description |
---|---|---|
SimpleCommand[] | commands | Collection of commands to be affected by validation failures. |
Remarks
Please call this method after instancing the commands.
Events
| Edit this page View SourceErrorsChanged
Triggered whenever validations are run.
Declaration
public event EventHandler<DataErrorsChangedEventArgs>? ErrorsChanged
Event Type
Type | Description |
---|---|
EventHandler<DataErrorsChangedEventArgs> |