Class BindableBase
Implements System.ComponentModel.INotifyPropertyChanged and System.IDisposable. Extension of Prisms BindableBase, see https://github.com/PrismLibrary/Prism/blob/7e73a697c4275acffb5e0a2205ccae14a9f22a84/Source/Prism/Mvvm/BindableBase.cs Adds overloads for SetProperty to automatically bind to INotifiyPropertyChanged and INotifyCollectionChanged events See the Prism Library license at https://github.com/PrismLibrary/Prism/blob/7e73a697c4275acffb5e0a2205ccae14a9f22a84/LICENSE
Inheritance
Implements
Inherited Members
Namespace: Dangl
Assembly: Dangl.Common.dll
Syntax
public abstract class BindableBase : INotifyPropertyChanged, IDisposable
Methods
| Improve this Doc View SourceDispose()
Implementation of System.IDisposable. Will always call the OnDispose() method that may be used in derived classes to implement behaviour upon being disposed, such as releasing event handler listeners.
Declaration
public void Dispose()
OnDispose()
This method is called by the Dispose() method upon disposing of this class via the System.IDisposable interface.
Declaration
protected virtual void OnDispose()
OnPropertyChanged(String)
Event to be raised for System.ComponentModel.INotifyPropertyChanged.
Declaration
protected virtual void OnPropertyChanged(string propertyName = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyName | Optional, when not given the System.Runtime.CompilerServices.CallerMemberNameAttribute is used to determine the calling function. |
SetProperty<T>(ref T, T, NotifyCollectionChangedEventHandler, String)
Checks if a property already matches a desired value. Sets the property and notifies listeners only when necessary. Will automatically attach the System.Collections.Specialized.NotifyCollectionChangedEventHandler to the new value and detach it from the old value.
Declaration
protected bool SetProperty<T>(ref T storage, T value, NotifyCollectionChangedEventHandler changeEventHook, string propertyName = null)
where T : INotifyCollectionChanged
Parameters
Type | Name | Description |
---|---|---|
T | storage | Reference to a property with both getter and setter. |
T | value | Desired value for the property. |
System.Collections.Specialized.NotifyCollectionChangedEventHandler | changeEventHook | |
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. |
SetProperty<T>(ref T, T, PropertyChangedEventHandler, String)
Checks if a property already matches a desired value. Sets the property and notifies listeners only when necessary. Will automatically attach the System.ComponentModel.PropertyChangedEventHandler to the new value and detach it from the old value.
Declaration
protected bool SetProperty<T>(ref T storage, T value, PropertyChangedEventHandler changeEventHook, string propertyName = null)
where T : INotifyPropertyChanged
Parameters
Type | Name | Description |
---|---|---|
T | storage | Reference to a property with both getter and setter. |
T | value | Desired value for the property. |
System.ComponentModel.PropertyChangedEventHandler | changeEventHook | |
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. |
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 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
| Improve this Doc View SourcePropertyChanged
System.ComponentModel.INotifyPropertyChanged implementation.
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type | Description |
---|---|
System.ComponentModel.PropertyChangedEventHandler |