开发者

Get binding target from source?

开发者 https://www.devze.com 2022-12-25 03:51 出处:网络
I have a ListView whose ItemsSource is bound to an ObservableCollection. The collection is filled with \"WaypointItem\" objects (a small class we defined with the info for the listview)开发者_高级运维

I have a ListView whose ItemsSource is bound to an ObservableCollection. The collection is filled with "WaypointItem" objects (a small class we defined with the info for the listview)开发者_高级运维.

The WaypointItem is our binding source for each row, but is there any magic way to get a reference to all objects (targets) binding to this class from within the WaypointItem code?

Thanks jason


There might be something helpful in the BindingOperations class. Unfortunately the Target of the binding is probably actually the DataContext of the item presenter (if I understand your description correctly), which means your WaypointItem probably can't tell what may be binding to it.

One slightly off-the-wall possibility would be to implement a custom IValueConverter that notifies your WaypointItem through a well-defined interface that it has been bound to something. It would send this notification on every update, so you would need to handle that appropriately.

0

精彩评论

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

关注公众号