Skip to content

Latest commit

 

History

History
81 lines (63 loc) · 2.55 KB

propertychangedeventhandler.md

File metadata and controls

81 lines (63 loc) · 2.55 KB
-api-id -api-type
T:Windows.UI.Xaml.Data.PropertyChangedEventHandler
winrt delegate

Windows.UI.Xaml.Data.PropertyChangedEventHandler

-description

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

-parameters

-param sender

The source of the event.

-param e

Event data.

-remarks

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

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

-see-also

Binding, XAML data binding sample, Data binding in depth