开发者

UpdateSourceTrigger's Default vs PropertyChanged?

<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?开发者_运维技巧


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.


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.


For TextBox Control When we use UpdateSourceTrigger=Default means when source object loses focus, value in target will get updated. When we use UpdateSourcetrigger=PropertyChanged means when source object text changes(even when we type a single character) immediately than change will be reflected in target. Above case is for TextBox control as default for most control is PropertyChanged only

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜