ListBox ScrollIntoView when using CollectionViewSource with GroupDescriptions (i.e. IsGrouping == True)

前端 未结 2 1035
太阳男子
太阳男子 2021-02-08 07:43

Short version

I would like to scroll the ListBox item into view when the selection is changed.

Long version

2条回答
  •  隐瞒了意图╮
    2021-02-08 07:52

    1. The out of the box VirtualizingStackPanel does not support virtualizing grouped collection views. When a grouped collection is rendered in an ItemsControl, each group as a whole is an item as opposed to each item in the collection which results in "jerky" scrolling to each group header and not each item.

    2. You'll probably need to roll your own VirtualizingStackPanel or ItemContainerGenerator in order to keep track of the containers displayed in a group. It sounds ridiculous, but the default virtualization with grouping in WPF is lacking to say the least.

提交回复
热议问题