Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Property Change Notification Events

Property change notification events are used to inform code when a property value changes either through internal or external activity. This allows the code to update related state as necessary (for example, by altering the appearance of a control in the user interface).

Consider raising change notification events when property values in high-level APIs (usually designer components) are modified.

This guideline applies to high-level members where change notification adds significant value to the library. For example, objects that provide or interact with the user interface use change notification to allow dependent UI objects to be updated accordingly. Change notification events should not be used where there is no value added to the library or where notification would be so frequent that it would significantly impact performance. For example, it is incorrect to raise a change notification event each time elements are added or removed from a general purpose collection. To avoid adding unneeded complexity to commonly used types, a special purpose collection should be used when this functionality is required. The .NET Framework version 2.0 libraries provide Collection<T> as a general purpose collection. For collections that require notification, the Framework also provides BindingList<T>.

Consider raising change notification events when the value of a property changes through external forces.

If a property value changes due to some external force such as user input, use a change notification event before the change is made permanent to indicate that the value will be changing. After the change is made permanent, use another event to signal that the value has changed. For example the Control class provides the Validating and Validated events to inform code of control validation.

Portions Copyright 2005 Microsoft Corporation. All rights reserved.

Portions Copyright Addison-Wesley Corporation. All rights reserved.

For more information on design guidelines, see the "Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries" book by Krzysztof Cwalina and Brad Abrams, published by Addison-Wesley, 2005.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.