Class BindableBase
Implementation of System.ComponentModel.INotifyPropertyChanged to simplify models.
Inheritance
Implements
Namespace: MAT.Atlas.Api.Core.Presentation
Assembly: MAT.Atlas.Api.Core.dll
Syntax
public abstract class BindableBase : Object, INotifyPropertyChanged
Constructors
BindableBase()
Declaration
protected BindableBase()
Methods
OnPropertyChanged(PropertyChangedEventArgs)
Raises the PropertyChanged event.
Declaration
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged(PropertyChangedEventArgs propertyChangedEventArgs)
Parameters
Type | Name | Description |
---|---|---|
System.ComponentModel.PropertyChangedEventArgs | propertyChangedEventArgs | The System.ComponentModel.PropertyChangedEventArgs instance containing the event data. |
OnPropertyChanged(String)
Notifies listeners that a property value has changed.
Declaration
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged(string propertyName = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyName | Name of the property used to notify listeners. This value is optional and can be provided automatically when invoked from compilers that support System.Runtime.CompilerServices.CallerMemberNameAttribute. |
Remarks
This code is been inspired from Prism Framework and then customized. See https://github.com/PrismLibrary/Prism/blob/master/Source/Prism/Mvvm/BindableBase.cs
SetProperty<T>(ref T, T, PropertyChangedEventArgs)
Checks if a property already matches a desired value. Sets the property and notifies listeners only when necessary.
Declaration
protected virtual bool SetProperty<T>(ref T storage, T value, PropertyChangedEventArgs propertyChangedEventArgs)
Parameters
Type | Name | Description |
---|---|---|
T | storage | Reference to a property with both getter and setter. |
T | value | Desired value for the property. |
System.ComponentModel.PropertyChangedEventArgs | propertyChangedEventArgs | The System.ComponentModel.PropertyChangedEventArgs instance containing the event data. |
Returns
Type | Description |
---|---|
System.Boolean | True if the value was changed, false if the existing value matched the desired value. |
Type Parameters
Name | Description |
---|---|
T | Type of the property. |
SetProperty<T>(ref T, T, String)
Checks if a property already matches a desired value. Sets the property and notifies listeners only when necessary.
Declaration
protected virtual bool SetProperty<T>(ref T storage, T value, string propertyName = null)
Parameters
Type | Name | Description |
---|---|---|
T | storage | Reference to a property with both getter and setter. |
T | value | Desired value for the property. |
System.String | propertyName | Name of the property used to notify listeners. This value is optional and can be provided automatically when invoked from compilers that support CallerMemberName. |
Returns
Type | Description |
---|---|
System.Boolean | True if the value was changed, false if the existing value matched the desired value. |
Type Parameters
Name | Description |
---|---|
T | Type of the property. |
Events
PropertyChanged
Occurs when a property value changes.
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type | Description |
---|---|
System.ComponentModel.PropertyChangedEventHandler |