Bagikan melalui


PropertyChangedEventHandler Delegasikan

Definisi

Mewakili metode yang akan menangani peristiwa PropertyChanged . Saat pemrograman dengan Microsoft .NET, delegasi ini disembunyikan, gunakan delegasi 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)

Parameter

sender
Object

IInspectable

Sumber dari peristiwa tersebut.

Atribut

Persyaratan Windows

Rangkaian perangkat
Windows 10 (diperkenalkan dalam 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v1.0)

Contoh

Contoh ini menunjukkan cara mengimplementasikan antarmuka INotifyPropertyChanged dan menggunakan PropertyChangedEventHandler. Untuk daftar kode lengkap, lihat sampel pengikatan data 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));
            }
        }
    }
}

Keterangan

Saat pemrograman dengan Microsoft .NET, delegasi ini disembunyikan. Pengembang Microsoft .NET harus menggunakan delegasi System.ComponentModel.PropertyChangedEventHandler .

Berlaku untuk

Lihat juga