PropertyChangedEventHandler 委托

定义

表示将处理 PropertyChanged 事件的方法。 使用 Microsoft .NET 编程时,此委托是隐藏的,请使用 System.ComponentModel.PropertyChangedEventHandler 委托。

/// [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)

参数

sender
Object

IInspectable

事件源。

属性

Windows 要求

设备系列
Windows 10 (在 10.0.10240.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)

示例

此示例演示如何实现 INotifyPropertyChanged 接口并使用 PropertyChangedEventHandler。 有关完整的代码列表,请参阅 XAML 数据绑定示例

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));
            }
        }
    }
}

注解

使用 Microsoft .NET 编程时,此委托是隐藏的。 Microsoft .NET 开发人员应使用 System.ComponentModel.PropertyChangedEventHandler 委托。

适用于

另请参阅