How to accomplish two-way data binding in WPF?

后端 未结 3 1397
不思量自难忘°
不思量自难忘° 2020-12-28 20:03

I have heard a lot about two-way bindings in WPF, but I\'m not entirely clear on how to accomplish it or what it actually means.

I have a ListView with

3条回答
  •  感动是毒
    2020-12-28 20:40

    If you haven't you'll need to implement INotifyPropertyChanged for your class that you're binding to.

    Also, when you say you want the ListBox item to be updated immediately, you mean that you want it to change as you type in the TextBox. By default the TextBox.Text property updates its source when it loses focus, but you can change this by setting the binding UpdateSourceTrigger to PropertyChanged:

    {Binding Source={...}, Path=Whatever, UpdateSourceTrigger=PropertyChanged}
    

提交回复
热议问题