Files
docs-desktop/dotnet-desktop-guide/framework/wpf/data/how-to-implement-property-change-notification.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

2.1 KiB

title, description, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title description ms.date dev_langs helpviewer_keywords ms.assetid
How to: Implement Property Change Notification Enable your properties to automatically notify a binding source when the property value changes in Windows Presentation Foundation (WPF). 03/30/2017
csharp
vb
notifications of change [WPF]
data binding [WPF], property change notifications
change notifications [WPF]
properties [WPF], change notifications
30b59d9e-8c3a-4349-aa82-4be837e841cf

How to: Implement Property Change Notification

To support xref:System.Windows.Data.BindingMode.OneWay or xref:System.Windows.Data.BindingMode.TwoWay binding to enable your binding target properties to automatically reflect the dynamic changes of the binding source (for example, to have the preview pane updated automatically when the user edits a form), your class needs to provide the proper property changed notifications. This example shows how to create a class that implements xref:System.ComponentModel.INotifyPropertyChanged.

Example

To implement xref:System.ComponentModel.INotifyPropertyChanged you need to declare the xref:System.ComponentModel.INotifyPropertyChanged.PropertyChanged event and create the OnPropertyChanged method. Then for each property you want change notifications for, you call OnPropertyChanged whenever the property is updated.

[!code-csharpSimpleBinding#PersonClass] [!code-vbSimpleBinding#PersonClass]

To see an example of how the Person class can be used to support xref:System.Windows.Data.BindingMode.TwoWay binding, see Control When the TextBox Text Updates the Source.

See also