0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

WPF VirtualizingPanel で仮想化する

Posted at

VirtualizingPanelでの仮想化について学習したことをまとめおく

整理:VirtualizingPanelについて
子要素が大量にある ItemsControl などのパネルに対して、仮想化されたスクロールアイテムを提供することができます。VirtualizingPanel を使用することで、UI パフォーマンスを向上させ、大量のアイテムを持つコントロールをより効率的に扱うことができます。

仮想化可能な子要素は、同じ型である必要があり、サイズを一定に保ち、再利用が可能である.
また、仮想化が有効になるためには、VirtualizingPanel の ScrollViewer.ScrollUnit プロパティが Item に設定されている必要がある

VirtualizingStackPanelを使って仮想化を有効化した簡単な実装例

<Grid>
    <ListBox Name="listBox" 
             VirtualizingStackPanel.IsVirtualizing="True"
             VirtualizingStackPanel.VirtualizationMode="Recycling">
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <VirtualizingStackPanel />
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
    </ListBox>
</Grid>

仮想化がOFFになる条件
①ListBoxなどのビューがグルーピングされている。
②ListBoxなどのCanContentScrollプロパティがfalseである。
  ※falseの場合、ピクセル単位でスクロールする(論理スクロール)。Trueの場合、ユニット(アイテム)単位でスクロールする(物理スクロール)

0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?