为清楚起见编辑:

我有2个listview我的应用程序。第一个包含列表>。列表中的项目的显示器被模板连接以仅显示密钥(字符串)。当用户在此列表中选择项目(选择中间)时,它将第二个ListView的项目源更改为Keypair的值。

这被放置在具有自动柱宽的网格内。

<ListView ItemsSource="{Binding Path=FunctionIndex.Index}"
          Name="completeFunctionIndexView"        
          Style="{StaticResource SearchListStyle}"
          SelectionChanged="functionIndexView_SelectionChanged" />

<ListView Name="SearchResults" 
          VirtualizingStackPanel.IsVirtualizing="True"
          VirtualizingStackPanel.VirtualizationMode="Recycling">
              <ListView.View>
                 <GridView >
                    <GridViewColumn 
                                 CellTemplate="{StaticResource ElementLV}"
                                 Width="Auto"/>
                 </GridView>
              </ListView.View>
           </ListView>
.

style searchliststyle仅介绍显示密钥的TextBlock(因为它包含键盘)。 ElementLV是一个小型文本块,其中包含绑定到我元素的不同属性和ToString值的运行。

private void functionIndexView_SelectionChanged(object sender, SelectionChangedEventArgs e)
     {
     //This supposes we want to support a "multiple selection search"
     //for now this isn't implemented
     List<Element> Results = new List<Element>();

     foreach (KeyValuePair<String, List<Element>> item in e.AddedItems)
        {
        Results = item.Value;
        break;
        }

     SearchResults.ItemsSource = Results;
     }
.

可以在SearchResults ListView中显示的这些列表可以具有大量元素(100k +)。我在第二个ListView上放了ISVirtualized,大部分时间就像魅力一样。

但有时,我不能将我的手指放在原因中的原因(咔哒咔哒咔哒她,也许可能是什么?),应用程序决定它必须生成列表中的所有项目(这是显然不想的)。 ..

有人可以指向我的正确方向吗?有没有原因是搜索结果将决定要求生成所有项目?

它可以链接到物品的宽度和SearchResults ListView,在测量时,试图测量其所有项目?

有帮助吗?

解决方案

I have found the situation which caused my List to generate all elements. It has to do with the ListView to have no specified Width, and beeing in a Container with Auto (a grid column with Auto ) as Width. It seems in certain condition which I'm not sure yet, the ListView tries to generate all the elements to measure their Width instead of using only those currently visible.

I'm think it didn't always do that, but in this particular situation in my application, now it does...

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top