ListView SelectAll() will not update properly

时间:2016-02-12 21:20:46

标签: c# wpf

I have two listviews. ListView A gets its items from one database(that works just fine) and ListView B gets its items from the selected items in ListView A. That also works fine, if I manually select all the items in ListView A.

The issue that I am having is: I have a button that is supposed to select all items in ListView A and by that load all Items that belong to ListView A in ListViewB.

The code I have for the button now is this:

 $file = cURL('https://www.google.com/search?num=30&hl=en&q=phpscript','http://www.google.ru',0,0,null);

When I click the button, it selects all the items in the ListView, but it doesn't seem to update correctly. So it gives ListView B, the disproportionate amount of items. If I then unselect and reselect an item in ListView A, it gives the correct amount of ListView B.

I hope I have explained well enough, and that someone has an idea of how to fix this.

Thank you for your help :)

EDIT: It seems like it is just updating the Items that are currently visible before you scroll down. So if I make ListViewA larger, it will add more items to ListViewB.

1 个答案:

答案 0 :(得分:0)

我弄清楚出了什么问题。基本上,列表视图中不在视图中的所有项都返回null。所以我只需要设置

VirtualizingStackPanel.IsVirtualizing="False"

在我的listview xaml。

然后列表视图将正确更新