我定义了集合类型的附加依赖项属性:
var selSrcPropMetadata = new PropertyMetadata(SelectionSourceChanged);
SelectionSourceProperty = DependencyProperty.RegisterAttached("SelectionSource",
typeof(IEnumerable),
typeof(SelectionHelper),
selSrcPropMetadata);
属性更改回调仅在应用绑定时起作用。 但如何获取有关绑定集合更改的通知?
答案 0 :(得分:2)
在SelectionSourceChanged中,检查新源值是否实现了INotifyCollectionChanged。如果是,请投射它并订阅其CollectionChanged事件。