INotifyPropertyChanged.PropertyChanged 이벤트

정의

속성 값이 변경될 때 발생합니다.

// Register
event_token PropertyChanged(PropertyChangedEventHandler const& handler) const;

// Revoke with event_token
void PropertyChanged(event_token const* cookie) const;

// Revoke with event_revoker
INotifyPropertyChanged::PropertyChanged_revoker PropertyChanged(auto_revoke_t, PropertyChangedEventHandler const& handler) const;
event PropertyChangedEventHandler PropertyChanged;
function onPropertyChanged(eventArgs) { /* Your code */ }
iNotifyPropertyChanged.addEventListener("propertychanged", onPropertyChanged);
iNotifyPropertyChanged.removeEventListener("propertychanged", onPropertyChanged);
- or -
iNotifyPropertyChanged.onpropertychanged = onPropertyChanged;
Event PropertyChanged As PropertyChangedEventHandler 

이벤트 유형

예제

이 예제에서는 INotifyPropertyChanged 인터페이스를 구현하고 속성 값이 변경될 때마다 PropertyChanged 이벤트를 실행하는 방법을 보여 줍니다. 전체 코드 목록은 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 Framework 사용하여 UWP 앱을 빌드할 때 이 인터페이스는 숨겨지고 개발자는 System.ComponentModel.INotifyPropertyChanged 인터페이스를 사용해야 합니다.

PropertyChanged 이벤트는 PropertyChangedEventArgsPropertyName 속성에 String.Empty를 사용하여 개체의 모든 속성이 변경되었음을 나타낼 수 있습니다. WPF(Windows Presentation Foundation) 및 Microsoft Silverlight에서처럼 null을 사용할 수 없습니다.

적용 대상

추가 정보