Notify (keyword)

From The Oxygene Language Wiki

(Redirected from Property Notifications)
Jump to:navigation, search

This is a Language topic
Feel free to add your notes to this topic below.



Property Notification

When notify is used on properties, the class will implicitly implement the System.ComponentModel.INotifyPropertyChanged and System.ComponentModel.INotifyPropertyChanging interface (if available, when linking against .NET 3.5, otherwise it will not be exposed) and invoke the event defined in that interface when the property itself is modified.

By default, it will pass the name of the property as defined in the class, however, notify supports a string parameter to change the name of the property passed to the event.

Defining

type
  ValueClass = class
  public
    property Value: Integer; notify;
    property Name: string; notify 'ValueName';
  end;


Using

var
  v: ValueClass;

v.PropertyChanged += 
  method (sender: Object; args: PropertyChangedEventArgs) 
  begin
    MessageBox.Show(String.Format('Someone changed the {0} property', args.PropertyName));
  end;


Compatibility Remarks


See Also


Oxygene-48.png

Area: Oxygene Language
Compiler version: Oxygene 5

Language GlossaryKeywordsTypesFAQHow To

Navigation
Areas
More
Toolbox