2

我创建了一个MultipleSelectionTreeView继承自的ItemsControl,由于数据量巨大,它使用了虚拟化。

当我在树中选择一个项目然后向下滚动并使用 Shift 键选择另一个项目时,两者之间的项目也应该被选中。

我使用此函数获取下一个项目,并将其设置为稍后选择:

    internal MultipleSelectionTreeViewItem GetNextNodeAtSameLevel()
    {
        MultipleSelectionTreeViewItem nextNodeAtSameLevel = null;

        ItemsControl parentControl = ParentItemsControl;
        if (parentControl != null)
        {
            int index = parentControl.ItemContainerGenerator.IndexFromContainer(this);
            if (index != parentControl.Items.Count - 1) // if this is not the last item
            {
                var item = ParentControl.ItemContainerGenerator.ContainerFromIndex(index + 1);
                nextNodeAtSameLevel = item as MultipleSelectionTreeViewItem;
            }
        }

        return nextNodeAtSameLevel;
    }

项目对我来说是空的。我知道这是因为虚拟化

有什么办法可以解决这个问题吗?或者创建我自己的虚拟化面板的唯一方法

4

0 回答 0