いつかすべてのアイテムを生成するように仮想化ListViewが何を原因とするのでしょうか。

StackOverflow https://stackoverflow.com/questions/9518201

質問

明快さのために編集された:

私の申請書を2つ持っています。最初のものにはリスト>が含まれています。リスト内の項目の表示はテンプレート化されています(文字列)。ユーザーがこのリストの項目を選択すると(SelectionChanged)、2番目のListViewのItemourceをキーペアの値に変更します。

これは、自動列幅のグリッドの内側に配置されています。

<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はキーを示すテキストブロックのみを閉じます(鍵ペアが含まれているため)。 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 +)を持つことができます。私は2番目のListViewに不透明化されています、そしてほとんどの時間は魅力のように機能します。

時々、私はそれを原因で私の指をかなり置くことができません(アイテムを選択するためにクリックしてください。)アプリケーションは、リスト内のすべての項目を生成する必要があります(これは明らかには望まれません)。

誰かが私を正しい方向に向けることができますか?検索結果がすべてのアイテムを生成するように頼むことを決定する理由はありますか?

測定時には、項目の幅と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