views:

221

answers:

1

Hello

I'm trying to implement my own VirtualWrapPanel in WPF.

I implement it this way :

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 the objects... Any idea ? Thanks Jonathan

A: 

Does your ItemsSource implement INotifyCollectionChanged? The easiest way to do that would to make it an ObservableCollection

Paul Betts