INotifyPropertyChanged.PropertyChanged event

Applies to Windows and Windows Phone

Occurs when a property value changes.

Syntax


event PropertyChangedEventHandler^ PropertyChanged {
   Windows::Foundation::EventRegistrationToken add(PropertyChangedEventHandler^ value);
   void remove(Windows::Foundation::EventRegistrationToken token);
}

Event information

Delegate PropertyChangedEventHandler

Remarks

When building Windows Store apps with the Microsoft .NET Framework, this interface is hidden and developers should use the System.ComponentModel.INotifyPropertyChanged interface.

The PropertyChanged event can indicate that all properties on the object have changed by using String.Empty for the PropertyName property of the PropertyChangedEventArgs. Note that you cannot use null for this like you can in Windows Presentation Foundation (WPF) and Microsoft Silverlight.

Examples

This example demonstrates how to implement the INotifyPropertyChanged interface and fire the PropertyChanged event whenever property values change. For the complete code listing, see the XAML data binding sample.


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataBinding
{
    public class Employee : INotifyPropertyChanged 
    {
        private string _name;
        private string _organization;

        public string Name
        {
            get { return _name; }
            set
            {
                _name = value;
                RaisePropertyChanged("Name");
            }
        }

        public string Organization
        {
            get { return _organization; }
            set
            {
                _organization = value;
                RaisePropertyChanged("Organization");
            }
        }


        public event PropertyChangedEventHandler PropertyChanged;
        protected void RaisePropertyChanged(string name)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(name));
            }
        }
    }
}


Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows::UI::Xaml::Data

Metadata

Windows.winmd

See also

INotifyPropertyChanged
Binding
XAML data binding sample
Data binding overview

 

 

Show:
© 2014 Microsoft. All rights reserved.