Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UpdateSourceTrigger's Default vs PropertyChanged?

Tags:

binding

wpf

<TextBlock Name="txtName" Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" />

"Name" is the property of an object which is bound with the TextBlock at runtime. I have implemented INotifyPropertyChanged so the code is working fine. My question is: if I replace PropertyChanged to Default will it still work? What's the difference between them?

like image 683
Jeevan Bhatt Avatar asked Dec 13 '10 09:12

Jeevan Bhatt


2 Answers

According to MSDN, the UpdateSourceTrigger's default value is PropertyChanged for most properties and LostFocus for the TextBox.Text property.

In your case, you're probably binding to a property for which the default is already set to PropertyChanged, so you won't see any difference.

like image 112
robertos Avatar answered Oct 16 '22 05:10

robertos


PropertyChanged is telling Binding that whenever you receive PropertyChanged notification for that property, update it's value on destination.

For some controls, like TextBox, using Default, it only updates binding destination when for example, it loses focus. When you set UpdateTrigger='PropertyChanged' on it, it will update binding destination while you are typing.

like image 44
decyclone Avatar answered Oct 16 '22 05:10

decyclone