ClassNotifyPropertyBase
Definition
Namespace:Telerik.WinControls.Data
Assembly:Telerik.WinControls.dll
Syntax:
public class NotifyPropertyBase : INotifyPropertyChangingEx, INotifyPropertyChanged
Inheritance: objectNotifyPropertyBase
Derived Classes:
Implements:
Constructors
NotifyPropertyBase()
Declaration
public NotifyPropertyBase()
Properties
IsSuspended
Declaration
[Browsable(false)]
public virtual bool IsSuspended { get; }
Property Value
Methods
OnPropertyChanged(PropertyChangedEventArgs)
Raises the PropertyChanged event
Declaration
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
Parameters
e
A PropertyChangedEventArgs instance containing event data.
OnPropertyChanged(string)
Raises the PropertyChanged event
Declaration
protected void OnPropertyChanged(string propertyName)
Parameters
propertyName
The name of the property
OnPropertyChanging(PropertyChangingEventArgsEx)
Raises the PropertyChanging event. Note: This method is called even when the notifications are suspended.
Declaration
protected virtual void OnPropertyChanging(PropertyChangingEventArgsEx e)
Parameters
e
A PropertyChangingEventArgsEx instance containing event data.
OnPropertyChanging(string)
Raises the PropertyChanging event
OnPropertyChanging(string, object, object)
Raises the PropertyChanging event
Declaration
protected PropertyChangingEventArgsEx OnPropertyChanging(string propertyName, object originalValue, object value)
Parameters
propertyName
The name of the property
originalValue
value
The value that is goint to be set to the property.
Returns
ProcessPropertyChanged(PropertyChangedEventArgs)
This method is called right befor the PropertyChanged event is fired.
Declaration
protected virtual void ProcessPropertyChanged(PropertyChangedEventArgs e)
Parameters
e
ProcessPropertyChanging(PropertyChangingEventArgsEx)
This method is called right before the PropertyChanging event is fired. Note: If IsSuspended is true, this method is not called.
Declaration
protected virtual void ProcessPropertyChanging(PropertyChangingEventArgsEx e)
Parameters
e
SetProperty<T>(string, ref T, T)
General method for setting the value of the field related to the property that is modified. This method confirms that the old and new values are different, then fires the PropertyChanging event, then sets the given value to the supplied field, and fires the PropertyChanged event. Note: If the PropertyChanging event is canceled, the last two actions are not performed.
Declaration
protected virtual bool SetProperty<T>(string propertyName, ref T propertyField, T value)
Parameters
propertyName
The name of the property, that will appear as propertyName in the PropertyChanging and PropertyChanged event args.
propertyField
T
The field, that is related to the property.
value
T
The value that is to be set to the field in case the PropertyChanging event is not being Cancel.
Returns
true if new value is being set
Example
public class MyNotificationsTest : NotifyPropertyBase
{
private int myInt = 0;
private int myInt2 = 0; //
public int AsInt
{
get
{
return this.myField;
}
set
{
if (SetProperty("AsInt", ref this.myInt, value))
{
// perform additional actions when new value is set to myInt.
}
}
}
public int AsInt2
{
get
{
return (float)this.myInt2;
}
set
{
// The following property setter is the same as the previous one.
if (this.myInt2 != value)
{
PropertyChangingEventArgs2 ea = new PropertyChangingEventArgs2("AsInt2", value);
OnPropertyChanging(ea);
if (!ea.Cancel)
{
this.myInt2 = (int)ea.Value;
OnPropertyChanged("AsInt2");
// perform additional actions when new value is set to myInt2.
}
}
}
}
}
Events
PropertyChanged
Occurs when a property of an object changes.
Declaration
public virtual event PropertyChangedEventHandler PropertyChanged
Event Value
Implements
PropertyChanging
Occurs before a property of an object changes.
Declaration
public virtual event PropertyChangingEventHandlerEx PropertyChanging
Event Value
Implements