Class ViewModelCommon
Base class recommended to use for view models across the application. Encapsulates implementations of INotifyPropertyChanged and INotifyDataErrorInfo.
Inherited Members
Namespace: BionicCode.Utilities.Net
Assembly: BionicCode.Utilities.Net.Common.dll
Syntax
public abstract class ViewModelCommon : IViewModelCommon, INotifyDataErrorInfo, IProgressReporterCommon, INotifyPropertyChanged
Constructors
| Improve this Doc View SourceViewModelCommon()
Default constructor
Declaration
protected ViewModelCommon()
Fields
| Improve this Doc View SourceDisableIndterminateMode
Constant representing value of NegativeInfinity. When assigned to Progress and when calling the default implementation of OnProgress(ProgressData) the value will automatically set IsIndeterminate to false.
Declaration
public const double DisableIndterminateMode = -Infinity
Field Value
| Type | Description |
|---|---|
| Double |
EnableIndterminateMode
Constant representing value of PositiveInfinity. When assigned to Progress and when calling the default implementation of OnProgress(ProgressData) the value will automatically set IsIndeterminate to true.
Declaration
public const double EnableIndterminateMode = Infinity
Field Value
| Type | Description |
|---|---|
| Double |
Properties
| Improve this Doc View SourceHasErrors
Declaration
public bool HasErrors { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
IsIndeterminate
Indicates that the progress reporting is indeterminate.
Declaration
public bool IsIndeterminate { get; set; }
Property Value
| Type | Description |
|---|---|
| Boolean |
IsReportingProgress
Indicates ongoing progress reporting
Declaration
public bool IsReportingProgress { get; set; }
Property Value
| Type | Description |
|---|---|
| Boolean |
Remarks
Raises PropertyChanged event.
ProgressText
The progress message.
Declaration
public string ProgressText { get; set; }
Property Value
| Type | Description |
|---|---|
| String |
Remarks
Raises PropertyChanged event.
ProgressValue
The progress value.
Declaration
public double ProgressValue { get; set; }
Property Value
| Type | Description |
|---|---|
| Double |
Remarks
Raises PropertyChanged event.
Methods
| Improve this Doc View SourceClearErrors(String)
Removes all error objects related to a property.
Declaration
protected virtual bool ClearErrors(string propertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| String | propertyName | The property to clear error objects for. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
CreateProgressReporterFromCurrentThread()
Creates a IProgress<T> instance that is associated with the caller's thread.
The registered progress callback is the virtual ViewModelCommon.OnProgress(ProgressData) member.
Declaration
public IProgress<ProgressData> CreateProgressReporterFromCurrentThread()
Returns
| Type | Description |
|---|---|
| IProgress<ProgressData> | A IProgress<T> instance that posts progress to the thread CreateProgressReporterFromCurrentThread() was called from. |
Remarks
To create a IProgress<T> instance that is associated with the application's primary dispatcher thread of a Windows targeting application, for example to update proerties that bind to a DispatcherObject, call CreateProgressReporterFromUiThread.
GetErrors(String)
Gets all error messages of the specified property. If the propertyName is null all error messages will be returned.
Declaration
public IEnumerable GetErrors(string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| String | propertyName | The of the property of which the error messages should be returned. |
Returns
| Type | Description |
|---|---|
| IEnumerable | An IEnumerable containing all error messages of the specified property. |
Remarks
If the propertyName is null all current error messages will be returned.
GetPropertyErrors(String)
Gets all error messages of the specified property. If the propertyName is null all error messages will be returned.
Declaration
public IEnumerable<string> GetPropertyErrors(string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| String | propertyName | The of the property of which the error messages should be returned. |
Returns
| Type | Description |
|---|---|
| IEnumerable<String> | Returns an IEnumerable<T> containing all error messages of the specified property. |
Remarks
If the propertyName is null all current error messages will be returned.
IsPropertyAttributeValid<TValue>(TValue, String)
Validates the value of a particular property against decorating validation attributes.
Declaration
protected virtual bool IsPropertyAttributeValid<TValue>(TValue value, string propertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The value to validate. |
| String | propertyName | The name of the property to validate. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TValue |
IsValueValid<TValue>(TValue, PropertyValidationDelegate<TValue>, String)
Can be used to check whether a value is valid.
Declaration
protected virtual bool IsValueValid<TValue>(TValue value, PropertyValidationDelegate<TValue> validationDelegate, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The value to check. |
| PropertyValidationDelegate<TValue> | validationDelegate | The validation delegate Func<T, TResult>which is invoked on the value. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TValue | Generic type parameter of the value to check. |
Remarks
When the propertyName value is null, the value is validated without generating an error. Validation errors are always related to a particular property.
IsValueValidAsync<TValue>(TValue, PropertyValidationDelegateAsync<TValue>, String)
Can be used to check whether a value is valid.
Declaration
protected virtual async Task<bool> IsValueValidAsync<TValue>(TValue value, PropertyValidationDelegateAsync<TValue> asyncValidationDelegate, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The value to check. |
| PropertyValidationDelegateAsync<TValue> | asyncValidationDelegate | The validation delegate Func<T, TResult>which is invoked on the value. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Task<Boolean> |
|
Type Parameters
| Name | Description |
|---|---|
| TValue | Generic type parameter of the value to check. |
Remarks
When the propertyName value is null, the value is validated without generating an error. Validation errors are always related to a particular property.
OnErrorsChanged(String)
Raised when the validation state of the view model has changed (e.g. error added or removed).
Declaration
protected virtual void OnErrorsChanged(string propertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| String | propertyName |
OnProgress(ProgressData)
When overridden, handles the Report(T) that is invoked by the IProgress<T> instance returned from CreateProgressReporterFromCurrentThread(). Can be used as progress delegate for any IProgress<T>.
Declaration
protected virtual void OnProgress(ProgressData progress)
Parameters
| Type | Name | Description |
|---|---|---|
| ProgressData | progress | The progress argument. |
Remarks
The default implementation provides the followwing logic: a value of NegativeInfinity or DisableIndterminateMode will automatically set the IsIndeterminate property to false. A value of PositiveInfinity or EnableIndterminateMode will automatically set the IsIndeterminate property to true.
OnProgressChanged(Double, Double)
Raises the ProgressChanged event.
Declaration
protected virtual void OnProgressChanged(double oldValue, double newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| Double | oldValue | The old progress value. |
| Double | newValue | The new progress value. |
OnProgressChanged(Double, Double, String)
Raises the ProgressChanged event.
Declaration
protected virtual void OnProgressChanged(double oldValue, double newValue, string progressText)
Parameters
| Type | Name | Description |
|---|---|---|
| Double | oldValue | The old progress value. |
| Double | newValue | The new progress value. |
| String | progressText | The progress message. |
OnPropertyChanged(Object, Object, String)
Method called to fire a PropertyChanged event. Also raises the PropertyChanged event to support binding.
Declaration
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged(object oldValue, object newValue, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | oldValue | The value before the property change. |
| Object | newValue | The value after the property change. |
| String | propertyName | The property name. |
OnPropertyChanged(String)
Method called to fire a PropertyChanged event. Also raises the PropertyChanged event to support binding.
Declaration
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged(string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| String | propertyName | The property name. |
PropertyHasError(String)
Checks whether the specified property has errors or is valid.
Declaration
public virtual bool PropertyHasError(string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| String | propertyName | The name of the property to check for errors. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
TrySetValue<TValue>(TValue, ref TValue, ViewModelCommon.SetValueOptions, String)
Generic property setter. Sets the value of any property of the extending view model by passing in a the corresponding property backing field. Automatically raises the PropertyChanged event for this property.
Declaration
protected virtual bool TrySetValue<TValue>(TValue value, ref TValue targetBackingField, ViewModelCommon.SetValueOptions methodConfiguration, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new property value. |
| TValue | targetBackingField | The backing field of the target property for the new value. Passed in by reference using |
| ViewModelCommon.SetValueOptions | methodConfiguration | Use to configure the method's behavior. |
| String | propertyName | The name of the property that changes. By default the property name is automatically set to the property that called this setter method. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic type parameter of the new property value. |
Remarks
Equality checking is enabled by default and must be explicitly disabled if needed by passing a ViewModelCommon.SetValueOptions to the apropriate overload. To determine equality ReferenceEquals(Object, Object) is called.
This means when the new property value value equals the old value, then the PropertyChanged event won't be raised.
To change the equality definition use an overload that accepts an IEqualityComparer<T> (for example TrySetValue<TValue>(TValue, ref TValue, IEqualityComparer<TValue>, String)).
To validate the value, use the TrySetValue<TValue>(TValue, Func<TValue, (Boolean IsValid, IEnumerable<Object> ErrorMessages)>, ref TValue, ViewModelCommon.SetValueOptions, IEqualityComparer<TValue>, String) method.
For asynchronous validation use the TrySetValueAsync<TValue>(TValue, TValue, Func<TValue, Task<(Boolean IsValid, IEnumerable<Object> ErrorMessages)>>, SetBackingFieldDelegate<TValue>, ViewModelCommon.SetValueOptions, IEqualityComparer<TValue>, String) method.
TrySetValue<TValue>(TValue, ref TValue, IEqualityComparer<TValue>, ViewModelCommon.SetValueOptions, String)
Generic property setter. Sets the value of any property of the extending view model by passing in a the corresponding property backing field. Automatically raises the PropertyChanged event for this property.
Declaration
protected virtual bool TrySetValue<TValue>(TValue value, ref TValue targetBackingField, IEqualityComparer<TValue> equalityComparer, ViewModelCommon.SetValueOptions methodConfiguration, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new property value. |
| TValue | targetBackingField | The backing field of the target property for the new value. Passed in by reference using |
| IEqualityComparer<TValue> | equalityComparer | A IEqualityComparer<T> to check for value equality.
|
| ViewModelCommon.SetValueOptions | methodConfiguration | Use to configure the method's behavior. |
| String | propertyName | The name of the property that changes. By default the property name is automatically set to the property that called this setter method. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic type parameter of the new property value. |
Remarks
Equality checking is enabled by default and must be explicitly disabled if needed by passing a ViewModelCommon.SetValueOptions to the apropriate overload. To determine equality ReferenceEquals(Object, Object) is called.
This means when the new property value value equals the old value, then the PropertyChanged event won't be raised. If equality checking is enabled and no IEqualityComparer<T> was provided by setting the equalityComparer parameter or the value is NULL,
the method will check for reference equality using ReferenceEquals(Object, Object).
To validate the value, use the TrySetValue<TValue>(TValue, Func<TValue, (Boolean IsValid, IEnumerable<Object> ErrorMessages)>, ref TValue, ViewModelCommon.SetValueOptions, IEqualityComparer<TValue>, String) method.
For asynchronous validation use the TrySetValueAsync<TValue>(TValue, TValue, Func<TValue, Task<(Boolean IsValid, IEnumerable<Object> ErrorMessages)>>, SetBackingFieldDelegate<TValue>, ViewModelCommon.SetValueOptions, IEqualityComparer<TValue>, String) method.
TrySetValue<TValue>(TValue, ref TValue, IEqualityComparer<TValue>, String)
Generic property setter. Sets the value of any property of the extending view model by passing in a the corresponding property backing field. Automatically raises the PropertyChanged event for this property.
Declaration
protected virtual bool TrySetValue<TValue>(TValue value, ref TValue targetBackingField, IEqualityComparer<TValue> equalityComparer, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new property value. |
| TValue | targetBackingField | The backing field of the target property for the new value. Passed in by reference using |
| IEqualityComparer<TValue> | equalityComparer | A IEqualityComparer<T> to check for value equality.
|
| String | propertyName | The name of the property that changes. By default the property name is automatically set to the property that called this setter method. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic type parameter of the new property value. |
Remarks
Equality checking is enabled by default and must be explicitly disabled if needed by passing a ViewModelCommon.SetValueOptions to the apropriate overload. To determine equality ReferenceEquals(Object, Object) is called.
This means when the new property value value equals the old value, then the PropertyChanged event won't be raised. If equality checking is enabled and no IEqualityComparer<T> was provided by setting the equalityComparer parameter or the value is NULL,
the method will check for reference equality using ReferenceEquals(Object, Object).
To validate the value, use the TrySetValue<TValue>(TValue, Func<TValue, (Boolean IsValid, IEnumerable<Object> ErrorMessages)>, ref TValue, ViewModelCommon.SetValueOptions, IEqualityComparer<TValue>, String) method.
For asynchronous validation use the TrySetValueAsync<TValue>(TValue, TValue, Func<TValue, Task<(Boolean IsValid, IEnumerable<Object> ErrorMessages)>>, SetBackingFieldDelegate<TValue>, ViewModelCommon.SetValueOptions, IEqualityComparer<TValue>, String) method.
TrySetValue<TValue>(TValue, ref TValue, String)
Generic property setter. Sets the value of any property of the extending view model by passing in a the corresponding property backing field. Automatically raises the PropertyChanged event for this property.
Declaration
protected virtual bool TrySetValue<TValue>(TValue value, ref TValue targetBackingField, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new property value. |
| TValue | targetBackingField | The backing field of the target property for the new value. Passed in by reference using |
| String | propertyName | The name of the property that changes. By default the property name is automatically set to the property that called this setter method. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic type parameter of the new property value. |
Remarks
Equality checking is enabled by default and must be explicitly disabled if needed by passing a ViewModelCommon.SetValueOptions to the apropriate overload. To determine equality ReferenceEquals(Object, Object) is called.
This means when the new property value value equals the old value, then the PropertyChanged event won't be raised.
To change the equality definition use an overload that accepts an IEqualityComparer<T> (for example TrySetValue<TValue>(TValue, ref TValue, IEqualityComparer<TValue>, String)).
To validate the value, use the TrySetValue<TValue>(TValue, Func<TValue, (Boolean IsValid, IEnumerable<Object> ErrorMessages)>, ref TValue, ViewModelCommon.SetValueOptions, IEqualityComparer<TValue>, String) method.
For asynchronous validation use the TrySetValueAsync<TValue>(TValue, TValue, Func<TValue, Task<(Boolean IsValid, IEnumerable<Object> ErrorMessages)>>, SetBackingFieldDelegate<TValue>, ViewModelCommon.SetValueOptions, IEqualityComparer<TValue>, String) method.
TrySetValue<TValue>(TValue, PropertyValidationDelegate<TValue>, ref TValue, ViewModelCommon.SetValueOptions, IEqualityComparer<TValue>, String)
Sets the value of the referenced property and executes a validation delegate.
Declaration
protected virtual bool TrySetValue<TValue>(TValue value, PropertyValidationDelegate<TValue> validationDelegate, ref TValue targetBackingField, ViewModelCommon.SetValueOptions methodConfiguration, IEqualityComparer<TValue> equalityComparer, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new value which is to be set to the property. |
| PropertyValidationDelegate<TValue> | validationDelegate | The callback that is used to validate the new value. |
| TValue | targetBackingField | The reference to the backing field. |
| ViewModelCommon.SetValueOptions | methodConfiguration | A ViewModelCommon.SetValueOptions object to configure the behavior of the method. |
| IEqualityComparer<TValue> | equalityComparer | A IEqualityComparer<T> to check for value equality. If this optional parameter is not provided ReferenceEquals(Object, Object) will be used. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Boolean | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the validationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
it is recommended to set methodConfiguration property IsThrowExceptionOnValidationErrorEnabled to true.
If not doing so, the binding target will clear the new value and show the last valid value instead.
If equality checking is enabled by setting the methodConfiguration parameter's property IsRejectEqualValuesEnabled to true (the parameter defaults to trur and the feature is always enabled by default) and the new value equals the old value, then the PropertyChanged event won't be raised.
If equality checking is enabled and no valid IEqualityComparer<T> was provided by setting the equalityComparer parameter, the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is NULL, the value is validated without generating an error. This is because validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if |
| ArgumentNullException | Thrown if |
TrySetValue<TValue>(TValue, PropertyValidationDelegate<TValue>, ref TValue, ViewModelCommon.SetValueOptions, String)
Sets the value of the referenced property and executes a validation delegate.
Declaration
protected virtual bool TrySetValue<TValue>(TValue value, PropertyValidationDelegate<TValue> validationDelegate, ref TValue targetBackingField, ViewModelCommon.SetValueOptions methodConfiguration, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new value which is to be set to the property. |
| PropertyValidationDelegate<TValue> | validationDelegate | The callback that is used to validate the new value. |
| TValue | targetBackingField | The reference to the backing field. |
| ViewModelCommon.SetValueOptions | methodConfiguration | A ViewModelCommon.SetValueOptions object to configure the behavior of the method. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Boolean | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the validationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
it is recommended to set methodConfiguration property IsThrowExceptionOnValidationErrorEnabled to true.
If not doing so, the binding target will clear the new value and show the last valid value instead.
If equality checking is enabled by setting the methodConfiguration parameter's property IsRejectEqualValuesEnabled to true (the parameter defaults to trur and the feature is always enabled by default) and the new value equals the old value, then the PropertyChanged event won't be raised.
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is NULL, the value is validated without generating an error. This is because validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if |
| ArgumentNullException | Thrown if |
TrySetValue<TValue>(TValue, PropertyValidationDelegate<TValue>, ref TValue, String)
Sets the value of the referenced property and executes a validation delegate.
Declaration
protected virtual bool TrySetValue<TValue>(TValue value, PropertyValidationDelegate<TValue> validationDelegate, ref TValue targetBackingField, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new value which is to be set to the property. |
| PropertyValidationDelegate<TValue> | validationDelegate | The callback that is used to validate the new value. |
| TValue | targetBackingField | The reference to the backing field. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Boolean | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the validationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
If not doing so, the binding target will clear the new value and show the last valid value instead.
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is NULL, the value is validated without generating an error. This is because validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
TrySetValue<TValue>(TValue, Func<TValue, (Boolean IsValid, IEnumerable<Object> ErrorMessages)>, ref TValue, ViewModelCommon.SetValueOptions, IEqualityComparer<TValue>, String)
Sets the value of the referenced property and executes a validation delegate.
Declaration
protected virtual bool TrySetValue<TValue>(TValue value, Func<TValue, (bool IsValid, IEnumerable<object> ErrorMessages)> validationDelegate, ref TValue targetBackingField, ViewModelCommon.SetValueOptions methodConfiguration, IEqualityComparer<TValue> equalityComparer, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new value which is to be set to the property. |
| Func<TValue, System.ValueTuple<Boolean, IEnumerable<Object>>> | validationDelegate | The callback that is used to validate the new value. |
| TValue | targetBackingField | The reference to the backing field. |
| ViewModelCommon.SetValueOptions | methodConfiguration | A ViewModelCommon.SetValueOptions object to configure the behavior of the method. |
| IEqualityComparer<TValue> | equalityComparer | A IEqualityComparer<T> to check for value equality. If this optional parameter is not provided ReferenceEquals(Object, Object) will be used. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Boolean | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the validationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
it is recommended to set methodConfiguration property IsThrowExceptionOnValidationErrorEnabled to true.
If not doing so, the binding target will clear the new value and show the last valid value instead.
If equality checking is enabled by setting the methodConfiguration parameter's property IsRejectEqualValuesEnabled to true (the parameter defaults to trur and the feature is always enabled by default) and the new value equals the old value, then the PropertyChanged event won't be raised.
If equality checking is enabled and no valid IEqualityComparer<T> was provided by setting the equalityComparer parameter, the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is NULL, the value is validated without generating an error. This is because validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if |
| ArgumentNullException | Thrown if |
TrySetValue<TValue>(TValue, Func<TValue, (Boolean IsValid, IEnumerable<Object> ErrorMessages)>, ref TValue, ViewModelCommon.SetValueOptions, String)
Sets the value of the referenced property and executes a validation delegate.
Declaration
protected virtual bool TrySetValue<TValue>(TValue value, Func<TValue, (bool IsValid, IEnumerable<object> ErrorMessages)> validationDelegate, ref TValue targetBackingField, ViewModelCommon.SetValueOptions methodConfiguration, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new value which is to be set to the property. |
| Func<TValue, System.ValueTuple<Boolean, IEnumerable<Object>>> | validationDelegate | The callback that is used to validate the new value. |
| TValue | targetBackingField | The reference to the backing field. |
| ViewModelCommon.SetValueOptions | methodConfiguration | A ViewModelCommon.SetValueOptions object to configure the behavior of the method. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Boolean | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the validationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
it is recommended to set methodConfiguration property IsThrowExceptionOnValidationErrorEnabled to true.
If not doing so, the binding target will clear the new value and show the last valid value instead.
If equality checking is enabled by setting the methodConfiguration parameter's property IsRejectEqualValuesEnabled to true (the parameter defaults to trur and the feature is always enabled by default) and the new value equals the old value, then the PropertyChanged event won't be raised.
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is NULL, the value is validated without generating an error. This is because validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if |
| ArgumentNullException | Thrown if |
TrySetValue<TValue>(TValue, Func<TValue, (Boolean IsValid, IEnumerable<Object> ErrorMessages)>, ref TValue, String)
Sets the value of the referenced property and executes a validation delegate.
Declaration
protected virtual bool TrySetValue<TValue>(TValue value, Func<TValue, (bool IsValid, IEnumerable<object> ErrorMessages)> validationDelegate, ref TValue targetBackingField, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new value which is to be set to the property. |
| Func<TValue, System.ValueTuple<Boolean, IEnumerable<Object>>> | validationDelegate | The callback that is used to validate the new value. |
| TValue | targetBackingField | The reference to the backing field. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Boolean | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the validationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
If not doing so, the binding target will clear the new value and show the last valid value instead.
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is NULL, the value is validated without generating an error. This is because validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
TrySetValueAsync<TValue>(TValue, TValue, PropertyValidationDelegateAsync<TValue>, SetBackingFieldDelegate<TValue>, ViewModelCommon.SetValueOptions, IEqualityComparer<TValue>, String)
Support for asynchronous validation. Sets the value of the referenced property and executes an asynchronous validation delegate.
Declaration
protected virtual async Task<bool> TrySetValueAsync<TValue>(TValue newValue, TValue oldValue, PropertyValidationDelegateAsync<TValue> asyncValidationDelegate, SetBackingFieldDelegate<TValue> backingFieldSetterDelegate, ViewModelCommon.SetValueOptions methodConfiguration, IEqualityComparer<TValue> equalityComparer, string propertyName = "")
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | newValue | The new value which is to be set to the property. |
| TValue | oldValue | The current value. |
| PropertyValidationDelegateAsync<TValue> | asyncValidationDelegate | The asynchronous callback that is used to validate the new value. |
| SetBackingFieldDelegate<TValue> | backingFieldSetterDelegate | A SetBackingFieldDelegate<TValue>. This delegate is required to set the backingfield of a property by an async method. Async methods can't define |
| ViewModelCommon.SetValueOptions | methodConfiguration | A ViewModelCommon.SetValueOptions object to configure the behavior of the method. |
| IEqualityComparer<TValue> | equalityComparer | A IEqualityComparer<T> to check for value equality. If this optional parameter is not provided ReferenceEquals(Object, Object) will be used. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Task<Boolean> | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the asyncValidationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
it is recommended to set methodConfiguration property IsThrowExceptionOnValidationErrorEnabled to true.
If not doing so, the binding target will clear the new value and show the last valid value instead.
If equality checking is enabled by setting the methodConfiguration parameter's property IsRejectEqualValuesEnabled to true (the parameter defaults to trur) and the new value equals the old value, then the PropertyChanged event won't be raised.
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the newValue is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if |
| ArgumentNullException | Thrown if |
TrySetValueAsync<TValue>(TValue, TValue, PropertyValidationDelegateAsync<TValue>, SetBackingFieldDelegate<TValue>, ViewModelCommon.SetValueOptions, String)
Support for asynchronous validation. Sets the value of the referenced property and executes an asynchronous validation delegate.
Declaration
protected virtual async Task<bool> TrySetValueAsync<TValue>(TValue newValue, TValue oldValue, PropertyValidationDelegateAsync<TValue> asyncValidationDelegate, SetBackingFieldDelegate<TValue> backingFieldSetterDelegate, ViewModelCommon.SetValueOptions methodConfiguration, string propertyName = "")
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | newValue | The new value which is to be set to the property. |
| TValue | oldValue | The current value. |
| PropertyValidationDelegateAsync<TValue> | asyncValidationDelegate | The asynchronous callback that is used to validate the new value. |
| SetBackingFieldDelegate<TValue> | backingFieldSetterDelegate | A SetBackingFieldDelegate<TValue>. This delegate is required to set the backingfield of a property by an async method. Async methods can't define |
| ViewModelCommon.SetValueOptions | methodConfiguration | A ViewModelCommon.SetValueOptions object to configure the behavior of the method. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Task<Boolean> | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the asyncValidationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
it is recommended to set methodConfiguration property IsThrowExceptionOnValidationErrorEnabled to true.
If not doing so, the binding target will clear the new value and show the last valid value instead.
If equality checking is enabled by setting the methodConfiguration parameter's property IsRejectEqualValuesEnabled to true (the parameter defaults to trur) and the new value equals the old value, then the PropertyChanged event won't be raised.
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the newValue is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if |
| ArgumentNullException | Thrown if |
TrySetValueAsync<TValue>(TValue, TValue, PropertyValidationDelegateAsync<TValue>, SetBackingFieldDelegate<TValue>, String)
Support for asynchronous validation. Sets the value of the referenced property and executes an asynchronous validation delegate.
Declaration
protected virtual async Task<bool> TrySetValueAsync<TValue>(TValue newValue, TValue oldValue, PropertyValidationDelegateAsync<TValue> asyncValidationDelegate, SetBackingFieldDelegate<TValue> backingFieldSetterDelegate, string propertyName = "")
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | newValue | The new value which is to be set to the property. |
| TValue | oldValue | The current value. |
| PropertyValidationDelegateAsync<TValue> | asyncValidationDelegate | The asynchronous callback that is used to validate the new value. |
| SetBackingFieldDelegate<TValue> | backingFieldSetterDelegate | A SetBackingFieldDelegate<TValue>. This delegate is required to set the backingfield of a property by an async method. Async methods can't define |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Task<Boolean> | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the asyncValidationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the newValue is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
TrySetValueAsync<TValue>(TValue, TValue, Func<TValue, Task<(Boolean IsValid, IEnumerable<Object> ErrorMessages)>>, SetBackingFieldDelegate<TValue>, ViewModelCommon.SetValueOptions, IEqualityComparer<TValue>, String)
Support for asynchronous validation. Sets the value of the referenced property and executes an asynchronous validation delegate.
Declaration
protected virtual async Task<bool> TrySetValueAsync<TValue>(TValue newValue, TValue oldValue, Func<TValue, Task<(bool IsValid, IEnumerable<object> ErrorMessages)>> asyncValidationDelegate, SetBackingFieldDelegate<TValue> backingFieldSetterDelegate, ViewModelCommon.SetValueOptions methodConfiguration, IEqualityComparer<TValue> equalityComparer, string propertyName = "")
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | newValue | The new value which is to be set to the property. |
| TValue | oldValue | The current value. |
| Func<TValue, Task<System.ValueTuple<Boolean, IEnumerable<Object>>>> | asyncValidationDelegate | The asynchronous callback that is used to validate the new value. |
| SetBackingFieldDelegate<TValue> | backingFieldSetterDelegate | A SetBackingFieldDelegate<TValue>. This delegate is required to set the backingfield of a property by an async method. Async methods can't define |
| ViewModelCommon.SetValueOptions | methodConfiguration | A ViewModelCommon.SetValueOptions object to configure the behavior of the method. |
| IEqualityComparer<TValue> | equalityComparer | A IEqualityComparer<T> to check for value equality. If this optional parameter is not provided ReferenceEquals(Object, Object) will be used. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Task<Boolean> | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the asyncValidationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
it is recommended to set methodConfiguration property IsThrowExceptionOnValidationErrorEnabled to true.
If not doing so, the binding target will clear the new value and show the last valid value instead.
If equality checking is enabled by setting the methodConfiguration parameter's property IsRejectEqualValuesEnabled to true (the parameter defaults to trur) and the new value equals the old value, then the PropertyChanged event won't be raised.
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the newValue is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if |
| ArgumentNullException | Thrown if |
TrySetValueAsync<TValue>(TValue, TValue, Func<TValue, Task<(Boolean IsValid, IEnumerable<Object> ErrorMessages)>>, SetBackingFieldDelegate<TValue>, ViewModelCommon.SetValueOptions, String)
Support for asynchronous validation. Sets the value of the referenced property and executes an asynchronous validation delegate.
Declaration
protected virtual async Task<bool> TrySetValueAsync<TValue>(TValue newValue, TValue oldValue, Func<TValue, Task<(bool IsValid, IEnumerable<object> ErrorMessages)>> asyncValidationDelegate, SetBackingFieldDelegate<TValue> backingFieldSetterDelegate, ViewModelCommon.SetValueOptions methodConfiguration, string propertyName = "")
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | newValue | The new value which is to be set to the property. |
| TValue | oldValue | The current value. |
| Func<TValue, Task<System.ValueTuple<Boolean, IEnumerable<Object>>>> | asyncValidationDelegate | The asynchronous callback that is used to validate the new value. |
| SetBackingFieldDelegate<TValue> | backingFieldSetterDelegate | A SetBackingFieldDelegate<TValue>. This delegate is required to set the backingfield of a property by an async method. Async methods can't define |
| ViewModelCommon.SetValueOptions | methodConfiguration | A ViewModelCommon.SetValueOptions object to configure the behavior of the method. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Task<Boolean> | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the asyncValidationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
it is recommended to set methodConfiguration property IsThrowExceptionOnValidationErrorEnabled to true.
If not doing so, the binding target will clear the new value and show the last valid value instead.
If equality checking is enabled by setting the methodConfiguration parameter's property IsRejectEqualValuesEnabled to true (the parameter defaults to trur) and the new value equals the old value, then the PropertyChanged event won't be raised.
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the newValue is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if |
| ArgumentNullException | Thrown if |
TrySetValueAsync<TValue>(TValue, TValue, Func<TValue, Task<(Boolean IsValid, IEnumerable<Object> ErrorMessages)>>, SetBackingFieldDelegate<TValue>, String)
Support for asynchronous validation. Sets the value of the referenced property and executes an asynchronous validation delegate.
Declaration
protected virtual async Task<bool> TrySetValueAsync<TValue>(TValue newValue, TValue oldValue, Func<TValue, Task<(bool IsValid, IEnumerable<object> ErrorMessages)>> asyncValidationDelegate, SetBackingFieldDelegate<TValue> backingFieldSetterDelegate, string propertyName = "")
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | newValue | The new value which is to be set to the property. |
| TValue | oldValue | The current value. |
| Func<TValue, Task<System.ValueTuple<Boolean, IEnumerable<Object>>>> | asyncValidationDelegate | The asynchronous callback that is used to validate the new value. |
| SetBackingFieldDelegate<TValue> | backingFieldSetterDelegate | A SetBackingFieldDelegate<TValue>. This delegate is required to set the backingfield of a property by an async method. Async methods can't define |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Task<Boolean> | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the asyncValidationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the newValue is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
TrySetValueSilent<TValue>(TValue, ref TValue, ViewModelCommon.SetValueOptions, IEqualityComparer<TValue>, String)
Generic property setter. Silently sets the value of any property of the extending view model by passing in a the corresponding property backing field. Suppresses a PropertyChanged event for this property.
Declaration
protected virtual bool TrySetValueSilent<TValue>(TValue value, ref TValue targetBackingField, ViewModelCommon.SetValueOptions methodConfiguration, IEqualityComparer<TValue> equalityComparer, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new property value. |
| TValue | targetBackingField | The backing field of the target property for the new value. Passed in by reference using |
| ViewModelCommon.SetValueOptions | methodConfiguration | A ViewModelCommon.SetValueOptions object to configure the behavior of the method. |
| IEqualityComparer<TValue> | equalityComparer | A IEqualityComparer<T> to check for value equality. If this optional parameter is not provided ReferenceEquals(Object, Object) will be used. |
| String | propertyName | The name of the property that changes. By default the property name is automatically set to the property that called this setter method. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic type parameter of the new property value. |
Remarks
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the value is validated without generating an error. Validation errors are always related to a particular property.
TrySetValueSilent<TValue>(TValue, ref TValue, ViewModelCommon.SetValueOptions, String)
Generic property setter. Silently sets the value of any property of the extending view model by passing in a the corresponding property backing field. Suppresses a PropertyChanged event for this property.
Declaration
protected virtual bool TrySetValueSilent<TValue>(TValue value, ref TValue targetBackingField, ViewModelCommon.SetValueOptions methodConfiguration, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new property value. |
| TValue | targetBackingField | The backing field of the target property for the new value. Passed in by reference using |
| ViewModelCommon.SetValueOptions | methodConfiguration | A ViewModelCommon.SetValueOptions object to configure the behavior of the method. |
| String | propertyName | The name of the property that changes. By default the property name is automatically set to the property that called this setter method. . |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic type parameter of the new property value. |
Remarks
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the value is validated without generating an error. Validation errors are always related to a particular property.
TrySetValueSilent<TValue>(TValue, ref TValue, IEqualityComparer<TValue>, String)
Generic property setter. Silently sets the value of any property of the extending view model by passing in a the corresponding property backing field. Suppresses a PropertyChanged event for this property.
Declaration
protected virtual bool TrySetValueSilent<TValue>(TValue value, ref TValue targetBackingField, IEqualityComparer<TValue> equalityComparer, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new property value. |
| TValue | targetBackingField | The backing field of the target property for the new value. Passed in by reference using |
| IEqualityComparer<TValue> | equalityComparer | A IEqualityComparer<T> to check for value equality. If this optional parameter is not provided ReferenceEquals(Object, Object) will be used. |
| String | propertyName | The name of the property that changes. By default the property name is automatically set to the property that called this setter method. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic type parameter of the new property value. |
Remarks
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the value is validated without generating an error. Validation errors are always related to a particular property.
TrySetValueSilent<TValue>(TValue, ref TValue, String)
Generic property setter. Silently sets the value of any property of the extending view model by passing in a the corresponding property backing field. Suppresses a PropertyChanged event for this property.
Declaration
protected virtual bool TrySetValueSilent<TValue>(TValue value, ref TValue targetBackingField, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new property value. |
| TValue | targetBackingField | The backing field of the target property for the new value. Passed in by reference using |
| String | propertyName | The name of the property that changes. By default the property name is automatically set to the property that called this setter method. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic type parameter of the new property value. |
Remarks
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the value is validated without generating an error. Validation errors are always related to a particular property.
TrySetValueSilent<TValue>(TValue, PropertyValidationDelegate<TValue>, ref TValue, ViewModelCommon.SetValueOptions, IEqualityComparer<TValue>, String)
Silently sets the value of the referenced property without raising PropertyChanged and executes a validation delegate.
Declaration
protected virtual bool TrySetValueSilent<TValue>(TValue value, PropertyValidationDelegate<TValue> validationDelegate, ref TValue targetBackingField, ViewModelCommon.SetValueOptions methodConfiguration, IEqualityComparer<TValue> equalityComparer, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new value which is to be set to the property. |
| PropertyValidationDelegate<TValue> | validationDelegate | The callback that is used to validate the new value. |
| TValue | targetBackingField | The reference to the backing field. |
| ViewModelCommon.SetValueOptions | methodConfiguration | A ViewModelCommon.SetValueOptions object to configure the behavior of the method. |
| IEqualityComparer<TValue> | equalityComparer | A IEqualityComparer<T> to check for value equality. If this optional parameter is not provided ReferenceEquals(Object, Object) will be used. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Boolean | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the validationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
it is recommended to set methodConfiguration property IsThrowExceptionOnValidationErrorEnabled to true.
If not doing so, the binding target will clear the new value and show the last valid value instead.
If equality checking is enabled by setting the methodConfiguration parameter's property IsRejectEqualValuesEnabled to true (the parameter defaults to trur) and the new value equals the old value, then the PropertyChanged event won't be raised.
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the value is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if |
| ArgumentNullException | Thrown if |
TrySetValueSilent<TValue>(TValue, PropertyValidationDelegate<TValue>, ref TValue, ViewModelCommon.SetValueOptions, String)
Silently sets the value of the referenced property without raising PropertyChanged and executes a validation delegate.
Declaration
protected virtual bool TrySetValueSilent<TValue>(TValue value, PropertyValidationDelegate<TValue> validationDelegate, ref TValue targetBackingField, ViewModelCommon.SetValueOptions methodConfiguration, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new value which is to be set to the property. |
| PropertyValidationDelegate<TValue> | validationDelegate | The callback that is used to validate the new value. |
| TValue | targetBackingField | The reference to the backing field. |
| ViewModelCommon.SetValueOptions | methodConfiguration | A ViewModelCommon.SetValueOptions object to configure the behavior of the method. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Boolean | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the validationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
it is recommended to set methodConfiguration property IsThrowExceptionOnValidationErrorEnabled to true.
If not doing so, the binding target will clear the new value and show the last valid value instead.
If equality checking is enabled by setting the methodConfiguration parameter's property IsRejectEqualValuesEnabled to true (the parameter defaults to trur) and the new value equals the old value, then the PropertyChanged event won't be raised.
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the value is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if |
| ArgumentNullException | Thrown if |
TrySetValueSilent<TValue>(TValue, PropertyValidationDelegate<TValue>, ref TValue, IEqualityComparer<TValue>, String)
Silently sets the value of the referenced property without raising PropertyChanged and executes a validation delegate.
Declaration
protected virtual bool TrySetValueSilent<TValue>(TValue value, PropertyValidationDelegate<TValue> validationDelegate, ref TValue targetBackingField, IEqualityComparer<TValue> equalityComparer, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new value which is to be set to the property. |
| PropertyValidationDelegate<TValue> | validationDelegate | The callback that is used to validate the new value. |
| TValue | targetBackingField | The reference to the backing field. |
| IEqualityComparer<TValue> | equalityComparer | A IEqualityComparer<T> to check for value equality. If this optional parameter is not provided ReferenceEquals(Object, Object) will be used. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Boolean | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the validationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the value is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
TrySetValueSilent<TValue>(TValue, PropertyValidationDelegate<TValue>, ref TValue, String)
Silently sets the value of the referenced property without raising PropertyChanged and executes a validation delegate.
Declaration
protected virtual bool TrySetValueSilent<TValue>(TValue value, PropertyValidationDelegate<TValue> validationDelegate, ref TValue targetBackingField, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new value which is to be set to the property. |
| PropertyValidationDelegate<TValue> | validationDelegate | The callback that is used to validate the new value. |
| TValue | targetBackingField | The reference to the backing field. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Boolean | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the validationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the value is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
TrySetValueSilent<TValue>(TValue, Func<TValue, (Boolean IsValid, IEnumerable<Object> ErrorMessages)>, ref TValue, ViewModelCommon.SetValueOptions, IEqualityComparer<TValue>, String)
Silently sets the value of the referenced property without raising PropertyChanged and executes a validation delegate.
Declaration
protected virtual bool TrySetValueSilent<TValue>(TValue value, Func<TValue, (bool IsValid, IEnumerable<object> ErrorMessages)> validationDelegate, ref TValue targetBackingField, ViewModelCommon.SetValueOptions methodConfiguration, IEqualityComparer<TValue> equalityComparer, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new value which is to be set to the property. |
| Func<TValue, System.ValueTuple<Boolean, IEnumerable<Object>>> | validationDelegate | The callback that is used to validate the new value. |
| TValue | targetBackingField | The reference to the backing field. |
| ViewModelCommon.SetValueOptions | methodConfiguration | A ViewModelCommon.SetValueOptions object to configure the behavior of the method. |
| IEqualityComparer<TValue> | equalityComparer | A IEqualityComparer<T> to check for value equality. If this optional parameter is not provided ReferenceEquals(Object, Object) will be used. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Boolean | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the validationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
it is recommended to set methodConfiguration property IsThrowExceptionOnValidationErrorEnabled to true.
If not doing so, the binding target will clear the new value and show the last valid value instead.
If equality checking is enabled by setting the methodConfiguration parameter's property IsRejectEqualValuesEnabled to true (the parameter defaults to trur) and the new value equals the old value, then the PropertyChanged event won't be raised.
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the value is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if |
| ArgumentNullException | Thrown if |
TrySetValueSilent<TValue>(TValue, Func<TValue, (Boolean IsValid, IEnumerable<Object> ErrorMessages)>, ref TValue, ViewModelCommon.SetValueOptions, String)
Silently sets the value of the referenced property without raising PropertyChanged and executes a validation delegate.
Declaration
protected virtual bool TrySetValueSilent<TValue>(TValue value, Func<TValue, (bool IsValid, IEnumerable<object> ErrorMessages)> validationDelegate, ref TValue targetBackingField, ViewModelCommon.SetValueOptions methodConfiguration, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new value which is to be set to the property. |
| Func<TValue, System.ValueTuple<Boolean, IEnumerable<Object>>> | validationDelegate | The callback that is used to validate the new value. |
| TValue | targetBackingField | The reference to the backing field. |
| ViewModelCommon.SetValueOptions | methodConfiguration | A ViewModelCommon.SetValueOptions object to configure the behavior of the method. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Boolean | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the validationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
it is recommended to set methodConfiguration property IsThrowExceptionOnValidationErrorEnabled to true.
If not doing so, the binding target will clear the new value and show the last valid value instead.
If equality checking is enabled by setting the methodConfiguration parameter's property IsRejectEqualValuesEnabled to true (the parameter defaults to trur) and the new value equals the old value, then the PropertyChanged event won't be raised.
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the value is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if |
| ArgumentNullException | Thrown if |
TrySetValueSilent<TValue>(TValue, Func<TValue, (Boolean IsValid, IEnumerable<Object> ErrorMessages)>, ref TValue, IEqualityComparer<TValue>, String)
Silently sets the value of the referenced property without raising PropertyChanged and executes a validation delegate.
Declaration
protected virtual bool TrySetValueSilent<TValue>(TValue value, Func<TValue, (bool IsValid, IEnumerable<object> ErrorMessages)> validationDelegate, ref TValue targetBackingField, IEqualityComparer<TValue> equalityComparer, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new value which is to be set to the property. |
| Func<TValue, System.ValueTuple<Boolean, IEnumerable<Object>>> | validationDelegate | The callback that is used to validate the new value. |
| TValue | targetBackingField | The reference to the backing field. |
| IEqualityComparer<TValue> | equalityComparer | A IEqualityComparer<T> to check for value equality. If this optional parameter is not provided ReferenceEquals(Object, Object) will be used. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Boolean | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the validationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the value is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
TrySetValueSilent<TValue>(TValue, Func<TValue, (Boolean IsValid, IEnumerable<Object> ErrorMessages)>, ref TValue, String)
Silently sets the value of the referenced property without raising PropertyChanged and executes a validation delegate.
Declaration
protected virtual bool TrySetValueSilent<TValue>(TValue value, Func<TValue, (bool IsValid, IEnumerable<object> ErrorMessages)> validationDelegate, ref TValue targetBackingField, string propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The new value which is to be set to the property. |
| Func<TValue, System.ValueTuple<Boolean, IEnumerable<Object>>> | validationDelegate | The callback that is used to validate the new value. |
| TValue | targetBackingField | The reference to the backing field. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Boolean | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the validationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the value is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
TrySetValueSilentAsync<TValue>(TValue, TValue, PropertyValidationDelegateAsync<TValue>, SetBackingFieldDelegate<TValue>, ViewModelCommon.SetValueOptions, IEqualityComparer<TValue>, String)
Silently sets the value of the referenced property without raising PropertyChanged and executes an asynchronous validation delegate.
Declaration
protected virtual async Task<bool> TrySetValueSilentAsync<TValue>(TValue newValue, TValue oldValue, PropertyValidationDelegateAsync<TValue> asyncValidationDelegate, SetBackingFieldDelegate<TValue> backingFieldSetterDelegate, ViewModelCommon.SetValueOptions methodConfiguration, IEqualityComparer<TValue> equalityComparer, string propertyName = "")
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | newValue | The new value which is to be set to the property. |
| TValue | oldValue | The current value. |
| PropertyValidationDelegateAsync<TValue> | asyncValidationDelegate | The asynchronous callback that is used to validate the new value. |
| SetBackingFieldDelegate<TValue> | backingFieldSetterDelegate | |
| ViewModelCommon.SetValueOptions | methodConfiguration | |
| IEqualityComparer<TValue> | equalityComparer | A IEqualityComparer<T> to check for value equality. If this optional parameter is not provided ReferenceEquals(Object, Object) will be used. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Task<Boolean> | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the asyncValidationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
it is recommended to set methodConfiguration property IsThrowExceptionOnValidationErrorEnabled to true.
If not doing so, the binding target will clear the new value and show the last valid value instead.
If equality checking is enabled by setting the methodConfiguration parameter's property IsRejectEqualValuesEnabled to true (the parameter defaults to trur) and the new value equals the old value, then the PropertyChanged event won't be raised.
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the newValue is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ArgumentException | Thrown if |
TrySetValueSilentAsync<TValue>(TValue, TValue, PropertyValidationDelegateAsync<TValue>, SetBackingFieldDelegate<TValue>, ViewModelCommon.SetValueOptions, String)
Silently sets the value of the referenced property without raising PropertyChanged and executes an asynchronous validation delegate.
Declaration
protected virtual async Task<bool> TrySetValueSilentAsync<TValue>(TValue newValue, TValue oldValue, PropertyValidationDelegateAsync<TValue> asyncValidationDelegate, SetBackingFieldDelegate<TValue> backingFieldSetterDelegate, ViewModelCommon.SetValueOptions methodConfiguration, string propertyName = "")
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | newValue | The new value which is to be set to the property. |
| TValue | oldValue | The current value. |
| PropertyValidationDelegateAsync<TValue> | asyncValidationDelegate | The asynchronous callback that is used to validate the new value. |
| SetBackingFieldDelegate<TValue> | backingFieldSetterDelegate | |
| ViewModelCommon.SetValueOptions | methodConfiguration | |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Task<Boolean> | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the asyncValidationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
it is recommended to set methodConfiguration property IsThrowExceptionOnValidationErrorEnabled to true.
If not doing so, the binding target will clear the new value and show the last valid value instead.
If equality checking is enabled by setting the methodConfiguration parameter's property IsRejectEqualValuesEnabled to true (the parameter defaults to trur) and the new value equals the old value, then the PropertyChanged event won't be raised.
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the newValue is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ArgumentException | Thrown if |
TrySetValueSilentAsync<TValue>(TValue, TValue, PropertyValidationDelegateAsync<TValue>, SetBackingFieldDelegate<TValue>, IEqualityComparer<TValue>, String)
Silently sets the value of the referenced property without raising PropertyChanged and executes an asynchronous validation delegate.
Declaration
protected virtual async Task<bool> TrySetValueSilentAsync<TValue>(TValue newValue, TValue oldValue, PropertyValidationDelegateAsync<TValue> asyncValidationDelegate, SetBackingFieldDelegate<TValue> backingFieldSetterDelegate, IEqualityComparer<TValue> equalityComparer, string propertyName = "")
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | newValue | The new value which is to be set to the property. |
| TValue | oldValue | The current value. |
| PropertyValidationDelegateAsync<TValue> | asyncValidationDelegate | The asynchronous callback that is used to validate the new value. |
| SetBackingFieldDelegate<TValue> | backingFieldSetterDelegate | |
| IEqualityComparer<TValue> | equalityComparer | A IEqualityComparer<T> to check for value equality. If this optional parameter is not provided ReferenceEquals(Object, Object) will be used. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Task<Boolean> | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the asyncValidationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the newValue is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
TrySetValueSilentAsync<TValue>(TValue, TValue, PropertyValidationDelegateAsync<TValue>, SetBackingFieldDelegate<TValue>, String)
Silently sets the value of the referenced property without raising PropertyChanged and executes an asynchronous validation delegate.
Declaration
protected virtual async Task<bool> TrySetValueSilentAsync<TValue>(TValue newValue, TValue oldValue, PropertyValidationDelegateAsync<TValue> asyncValidationDelegate, SetBackingFieldDelegate<TValue> backingFieldSetterDelegate, string propertyName = "")
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | newValue | The new value which is to be set to the property. |
| TValue | oldValue | The current value. |
| PropertyValidationDelegateAsync<TValue> | asyncValidationDelegate | The asynchronous callback that is used to validate the new value. |
| SetBackingFieldDelegate<TValue> | backingFieldSetterDelegate | |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Task<Boolean> | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the asyncValidationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the newValue is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
TrySetValueSilentAsync<TValue>(TValue, TValue, Func<TValue, Task<(Boolean IsValid, IEnumerable<Object> ErrorMessages)>>, SetBackingFieldDelegate<TValue>, ViewModelCommon.SetValueOptions, IEqualityComparer<TValue>, String)
Silently sets the value of the referenced property without raising PropertyChanged and executes an asynchronous validation delegate.
Declaration
protected virtual async Task<bool> TrySetValueSilentAsync<TValue>(TValue newValue, TValue oldValue, Func<TValue, Task<(bool IsValid, IEnumerable<object> ErrorMessages)>> asyncValidationDelegate, SetBackingFieldDelegate<TValue> backingFieldSetterDelegate, ViewModelCommon.SetValueOptions methodConfiguration, IEqualityComparer<TValue> equalityComparer, string propertyName = "")
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | newValue | The new value which is to be set to the property. |
| TValue | oldValue | The current value. |
| Func<TValue, Task<System.ValueTuple<Boolean, IEnumerable<Object>>>> | asyncValidationDelegate | The asynchronous callback that is used to validate the new value. |
| SetBackingFieldDelegate<TValue> | backingFieldSetterDelegate | |
| ViewModelCommon.SetValueOptions | methodConfiguration | |
| IEqualityComparer<TValue> | equalityComparer | A IEqualityComparer<T> to check for value equality. If this optional parameter is not provided ReferenceEquals(Object, Object) will be used. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Task<Boolean> | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the asyncValidationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
it is recommended to set methodConfiguration property IsThrowExceptionOnValidationErrorEnabled to true.
If not doing so, the binding target will clear the new value and show the last valid value instead.
If equality checking is enabled by setting the methodConfiguration parameter's property IsRejectEqualValuesEnabled to true (the parameter defaults to trur) and the new value equals the old value, then the PropertyChanged event won't be raised.
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the newValue is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ArgumentException | Thrown if |
TrySetValueSilentAsync<TValue>(TValue, TValue, Func<TValue, Task<(Boolean IsValid, IEnumerable<Object> ErrorMessages)>>, SetBackingFieldDelegate<TValue>, ViewModelCommon.SetValueOptions, String)
Silently sets the value of the referenced property without raising PropertyChanged and executes an asynchronous validation delegate.
Declaration
protected virtual async Task<bool> TrySetValueSilentAsync<TValue>(TValue newValue, TValue oldValue, Func<TValue, Task<(bool IsValid, IEnumerable<object> ErrorMessages)>> asyncValidationDelegate, SetBackingFieldDelegate<TValue> backingFieldSetterDelegate, ViewModelCommon.SetValueOptions methodConfiguration, string propertyName = "")
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | newValue | The new value which is to be set to the property. |
| TValue | oldValue | The current value. |
| Func<TValue, Task<System.ValueTuple<Boolean, IEnumerable<Object>>>> | asyncValidationDelegate | The asynchronous callback that is used to validate the new value. |
| SetBackingFieldDelegate<TValue> | backingFieldSetterDelegate | |
| ViewModelCommon.SetValueOptions | methodConfiguration | |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Task<Boolean> | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the asyncValidationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
it is recommended to set methodConfiguration property IsThrowExceptionOnValidationErrorEnabled to true.
If not doing so, the binding target will clear the new value and show the last valid value instead.
If equality checking is enabled by setting the methodConfiguration parameter's property IsRejectEqualValuesEnabled to true (the parameter defaults to trur) and the new value equals the old value, then the PropertyChanged event won't be raised.
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the newValue is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ArgumentException | Thrown if |
TrySetValueSilentAsync<TValue>(TValue, TValue, Func<TValue, Task<(Boolean IsValid, IEnumerable<Object> ErrorMessages)>>, SetBackingFieldDelegate<TValue>, IEqualityComparer<TValue>, String)
Silently sets the value of the referenced property without raising PropertyChanged and executes an asynchronous validation delegate.
Declaration
protected virtual async Task<bool> TrySetValueSilentAsync<TValue>(TValue newValue, TValue oldValue, Func<TValue, Task<(bool IsValid, IEnumerable<object> ErrorMessages)>> asyncValidationDelegate, SetBackingFieldDelegate<TValue> backingFieldSetterDelegate, IEqualityComparer<TValue> equalityComparer, string propertyName = "")
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | newValue | The new value which is to be set to the property. |
| TValue | oldValue | The current value. |
| Func<TValue, Task<System.ValueTuple<Boolean, IEnumerable<Object>>>> | asyncValidationDelegate | The asynchronous callback that is used to validate the new value. |
| SetBackingFieldDelegate<TValue> | backingFieldSetterDelegate | |
| IEqualityComparer<TValue> | equalityComparer | A IEqualityComparer<T> to check for value equality. If this optional parameter is not provided ReferenceEquals(Object, Object) will be used. |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Task<Boolean> | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the asyncValidationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the newValue is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
TrySetValueSilentAsync<TValue>(TValue, TValue, Func<TValue, Task<(Boolean IsValid, IEnumerable<Object> ErrorMessages)>>, SetBackingFieldDelegate<TValue>, String)
Silently sets the value of the referenced property without raising PropertyChanged and executes an asynchronous validation delegate.
Declaration
protected virtual async Task<bool> TrySetValueSilentAsync<TValue>(TValue newValue, TValue oldValue, Func<TValue, Task<(bool IsValid, IEnumerable<object> ErrorMessages)>> asyncValidationDelegate, SetBackingFieldDelegate<TValue> backingFieldSetterDelegate, string propertyName = "")
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | newValue | The new value which is to be set to the property. |
| TValue | oldValue | The current value. |
| Func<TValue, Task<System.ValueTuple<Boolean, IEnumerable<Object>>>> | asyncValidationDelegate | The asynchronous callback that is used to validate the new value. |
| SetBackingFieldDelegate<TValue> | backingFieldSetterDelegate | |
| String | propertyName | The name of the property to set. Default name is the property that called this method.
|
Returns
| Type | Description |
|---|---|
| Task<Boolean> | Returns |
Type Parameters
| Name | Description |
|---|---|
| TValue | The generic value type parameter |
Remarks
This property setter supports invalid value rejection, which means values are only assigned to the backing field if they are valid which is when the asyncValidationDelegate return true.
To support visual validation error feed back and proper behavior in TwoWay binding scenarios where the validation mode Binding.ValidatesOnExceptions of the System.Windows.Binding is set to true,
Equality checking is enabled by default and the method will check for reference equality using ReferenceEquals(Object, Object).
When the propertyName value is null, the newValue is validated without generating an error. Validation errors are always related to a particular property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
Events
| Improve this Doc View SourceErrorsChanged
Declaration
public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged
Event Type
| Type | Description |
|---|---|
| EventHandler<DataErrorsChangedEventArgs> |
ProgressChanged
Raised when ProgressValue, ProgressText or IsIndeterminate has changed.
Declaration
public event ProgressChangedEventHandler ProgressChanged
Event Type
| Type | Description |
|---|---|
| ProgressChangedEventHandler |
PropertyChanged
Event fired whenever a child property changes its value.
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
| Type | Description |
|---|---|
| PropertyChangedEventHandler |
PropertyValueChanged
PropertyChanged implementation that sends old value and new value of the change and raises the INotifyPropertyChanged event.
Declaration
public event PropertyValueChangedEventHandler<object> PropertyValueChanged
Event Type
| Type | Description |
|---|---|
| PropertyValueChangedEventHandler<Object> |