OnItemChanged not called when trying to implement VirtualizingPanel in WPF

I am trying to implement my own VirtualWrapPanel in WPF.

I am implementing it like this:

public class VirtualWrapPanel : VirtualizingPanel, IScrollInfo
    {

         ....

    protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
        {
            switch (args.Action)
            {
                case NotifyCollectionChangedAction.Remove:
                case NotifyCollectionChangedAction.Replace:
                case NotifyCollectionChangedAction.Move:
                    base.RemoveInternalChildRange(args.Position.Index, args.ItemUICount);
                    return;
            }
        }

}

      

but the OnItemsChanged method is never called, causing the control not to release objects ... Any ideas? thanks Jonathan

0


source to share


1 answer


Is your ItemSource using INotifyCollectionChanged? The easiest way to do this is to make an ObservableCollection



0


source







All Articles