WPF update binding to element in an array

前端 未结 6 1505
野趣味
野趣味 2021-01-02 16:06

I\'ve searched my little heart out and its entirely possible that I\'m missing something critical and obvious.

I have a BitArray and a series of checkboxes that are

6条回答
  •  长情又很酷
    2021-01-02 16:23

    Again, this TextBox gets the name from the binding just fine, but doesn't hit the setter if I change it.

    It doesn't need to call the setter: the binding doesn't replace the array, it simply replaces an element of the array. If you check the values in the array, you will see that they reflect the changes.

    It also works fine with a BitArray (I just tried with both an array and a BitArray).

    However, arrays (and BitArray) don't implement INotifyPropertyChanged or INotifyCollectionChanged, so if there are other bindings to the values in the array, they won't be refreshed automatically. You will need a wrapper that implements these interfaces (ObservableCollection for instance)

提交回复
热议问题