문제

명확성을 위해 편집 :

2 ListView i가 내 응용 프로그램을 가지고 있습니다. 첫 번째 프로그램에는 > 목록이 들어 있습니다. 목록에있는 항목의 표시가 템플릿이되어 키 (문자열) 만 표시합니다. 사용자 가이 목록 (SelectionChanged)의 항목을 선택하면 두 번째 ListView의 itemsource를 키 쌍의 값으로 변경합니다.

이는 자동 너비가있는 그리드 안에 배치됩니다.

<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>
.

스타일 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 +)를 가질 수 있습니다. 나는 iSvirtualizing을 두 번째 ListView에 넣고 매력처럼 작동하는 대부분의 시간입니다.

그러나 때로는 손가락을 멈출 수 없습니다 (너무 빨리 항목을 선택 하시려면 클릭하십시오.) 응용 프로그램은 목록의 모든 항목을 생성해야합니다 (명백하게 원하지 않는). ..

누군가가 나를 올바른 방향으로 가리킬 수 있습니까? SearchResults가 모든 항목을 생성하도록 요청하기로 결정한 이유가 있습니까?

항목의 너비와 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