Skip to end of metadata
Go to start of metadata

Represent a base class for model.

Definition

public abstract class ModelBase : IDisposable,

INotifyPropertyChanged, INotifyDataErrorInfo

Summary

The following table summarizes the members exposed in this class.

Protected Constructors

Public Properties

HasErrors Gets a value that indicates whether the entity has validation errors.

Public Methods

AddError(string, string) Add error string for specified property.
ClearError(string) Remove all error strings of specified property.
ClearErrors() Remove all error strings.
Dispose() Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
GetErrors(string) Gets the validation errors for a specified property or for the entire entity.
RemoveError(string, string) Remove error string of specified property.

Protected Methods

OnErrorsChanged(string) Called when the errors has changed.
OnPropertyChanged(string) Called when the property value has changed.

Events

ErrorsChanged Occurs when the validation errors have changed for a property or for the entire entity.
PropertyChanged Occurs when a property value changes.

Protected Constructors

protected ModelBase()

Public Properties

public bool HasErrors { get; }

Gets a value that indicates whether the entity has validation errors.

Public Methods

public void AddError(string propertyName, string error)

Add error string for specified property.

Parameters

propertyName The property name.
error The error string.

public void ClearError(string propertyName)

Remove all error strings of specified property.

Parameters

propertyName The property name.

public void ClearErrors()

Remove all error strings.

public void Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public IEnumerable GetErrors(string propertyName)

Gets the validation errors for a specified property or for the entire entity.

Parameters

propertyName The name of the property to retrieve validation errors for; or null or System.String.Empty, to retrieve entity-level errors.

Return Types

The validation errors for the property or entity.

public void RemoveError(string propertyName, string error)

Remove error string of specified property.

Parameters

propertyName The property name.
error The error string.

Protected Methods

protected void OnErrorsChanged(string propertyName)

Called when the errors has changed.

Parameters

propertyName

protected void OnPropertyChanged(string propertyName)

Called when the property value has changed.

Parameters

propertyName The property name.

Events

public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged

Occurs when the validation errors have changed for a property or for the entire entity.

public event PropertyChangedEventHandler PropertyChanged

Occurs when a property value changes.

  • No labels