2012-12-10 44 views
1

我定義集合類型的附加依賴屬性:如何獲取有關綁定集合中更改的通知?

var selSrcPropMetadata = new PropertyMetadata(SelectionSourceChanged); 
SelectionSourceProperty = DependencyProperty.RegisterAttached("SelectionSource", 
                 typeof(IEnumerable), 
                 typeof(SelectionHelper), 
                 selSrcPropMetadata); 

屬性更改回調只能在綁定應用於一次。 但是如何獲取有關綁定收集更改的通知

回答

2

在SelectionSourceChanged中,檢查新的源值是否實現INotifyCollectionChanged。如果確實如此,則將其投射並訂閱其CollectionChanged事件。

+0

它肯定會導致ICollectionView繼承INotifyCollectionChanged。錯誤地看着CollectionViewSource。謝謝。 –

相關問題