INotifyPropertyChanged.PropertyChanged event

Expand
0 out of 1 rated this helpful - Rate this topic

INotifyPropertyChanged.PropertyChanged event

[This documentation is preliminary and is subject to change.]

Occurs when a property value changes.

Syntax


event PropertyChangedEventHandler PropertyChanged

Event information

Delegate PropertyChangedEventHandler

Remarks

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 (Nothing in Visual Basic) for this like you can in Windows Presentation Foundation (WPF) and Microsoft Silverlight.

Examples

This example demonstrates how to implement the INotifyPropertyChanged interface and raise the PropertyChanged event whenever property values change. For the complete code listing, see the 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 Release Preview

Minimum supported server

Windows Server 2012

Namespace

Windows.UI.Xaml.Data
Windows::UI::Xaml::Data [C++]

Metadata

Windows.winmd

See also

INotifyPropertyChanged
Binding
Data Binding sample
Data binding with XAML

 

 

Build date: 5/22/2012

Did you find this helpful?
(1500 characters remaining)
Community Additions ADD