Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

INotifyPropertyChanged Interface

Notifies clients that a property value has changed.

Namespace:  System.ComponentModel
Assembly:  System (in System.dll)

'Declaration
Public Interface INotifyPropertyChanged

The INotifyPropertyChanged type exposes the following members.

  NameDescription
Public eventSupported by Silverlight for Windows PhoneSupported by Xbox 360PropertyChangedOccurs when a property value changes.
Top

The INotifyPropertyChanged interface is used to notify clients, typically binding clients, that a property value has changed.

For example, consider a Person object with a property called FirstName. To provide generic property-change notification, the Person type implements the INotifyPropertyChanged interface and raises a PropertyChanged event when FirstName is changed.

The following code example demonstrates the how to implement the INotifyPropertyChanged interface.


'Add Imports statements 
Imports System.ComponentModel
Imports System.Windows.Data


...


' Create a class that implements INotifyPropertyChanged 
Public Class Person
    Implements INotifyPropertyChanged

    Private firstNameValue As String
    Public Property FirstName() As String
        Get
            Return firstNameValue
        End Get
        Set(ByVal value As String)
            firstNameValue = value
            ' Call NotifyPropertyChanged when the property is updated 
            NotifyPropertyChanged("FirstName")
        End Set
    End Property

    ' Declare the PropertyChanged event 
    Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged

    ' NotifyPropertyChanged will raise the PropertyChanged event passing the 
    ' source property that is being updated. 
    Public Sub NotifyPropertyChanged(ByVal propertyName As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
    End Sub
End Class


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2015 Microsoft