Sdílet prostřednictvím


PropertyChangedEventHandler Delegate

Definition

Represents the method that will handle the PropertyChanged event. When programming with Microsoft .NET this delegate is hidden, use the System.ComponentModel.PropertyChangedEventHandler delegate.

/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.Guid(1358011414, 2594, 19854, 160, 137, 30, 169, 149, 22, 87, 210)]
class PropertyChangedEventHandler : MulticastDelegate
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.Guid(1358011414, 2594, 19854, 160, 137, 30, 169, 149, 22, 87, 210)]
public delegate void PropertyChangedEventHandler(object sender, PropertyChangedEventArgs e);
Public Delegate Sub PropertyChangedEventHandler(sender As Object, e As PropertyChangedEventArgs)

Parameters

sender
Object

IInspectable

The source of the event.

Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Examples

This example demonstrates how to implement the INotifyPropertyChanged interface and use PropertyChangedEventHandler. 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));
            }
        }
    }
}

Remarks

When programming with Microsoft .NET, this delegate is hidden. Microsoft .NET Developers should use the System.ComponentModel.PropertyChangedEventHandler delegate.

Applies to

See also