Virtualizing WPF Wrap Panel Issue

前端 未结 3 618
眼角桃花
眼角桃花 2020-12-15 12:10

There are not very many options for a virtualizing wrap panel for use in WPF. For one reason or another MS decided to not ship one in the standard library.

If anyon

3条回答
  •  旧时难觅i
    2020-12-15 12:26

    The OnItemsChanged method needs to properly handle the args parameters. Please see this question for more information. Copying the code from that question, you would need to update OnItemsChanged like so:

    protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args) {
        base.OnItemsChanged(sender, args);
        _abstractPanel = null;
        ResetScrollInfo();
    
        // ...ADD THIS...
        switch (args.Action) {
            case NotifyCollectionChangedAction.Remove:
            case NotifyCollectionChangedAction.Replace:
                RemoveInternalChildRange(args.Position.Index, args.ItemUICount);
                break;
            case NotifyCollectionChangedAction.Move:
                RemoveInternalChildRange(args.OldPosition.Index, args.ItemUICount);
                break;
        }
    }
    

提交回复
热议问题