Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF TreeView Virtualization
    primarykey
    data
    text
    <p>I'm trying to figure out this virtualization feature, I'm not sure if I'm understanding it wrong or what's going on, but I'm using the ANTS memory profiler to check the number of items in a virtualized TreeView, and it just keeps increasing. I have a TreeView with 1,001 items (1 root, 1000 sub-items), and I always get up to 1,001 TreeViewItems, 1,001 ToggleButtons and 1,001 TextBlocks. Isn't virtualization supposed to re-use the items? If so, why would I have 1,001 of each? Also, the CleanUpVirtualizedItem never fires.</p> <p>Let me know if I'm understanding this wrong and if you have resources on how to use this. I've searched over the internet but haven't found anything useful.</p> <p><strong>EDIT:</strong></p> <p>Even the memory used by the tree grows from aporx. 4mb to 12mb when I expand and scroll through all the items.</p> <p>Let me know thanks.</p> <p>This is my code.</p> <p>XAML:</p> <pre><code>&lt;Window x:Class="RadTreeViewExpandedProblem.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"&gt; &lt;Grid&gt; &lt;TreeView x:Name="treeView" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.CleanUpVirtualizedItem="TreeView_CleanUpVirtualizedItem"&gt; &lt;TreeView.ItemsPanel&gt; &lt;ItemsPanelTemplate&gt; &lt;VirtualizingStackPanel /&gt; &lt;/ItemsPanelTemplate&gt; &lt;/TreeView.ItemsPanel&gt; &lt;/TreeView&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>C#: </p> <pre><code> public partial class Window1 : Window { public Window1() { InitializeComponent(); TreeViewItem rootItem = new TreeViewItem() { Header = "Item Level 0" }; for (int i = 0; i &lt; 1000; i++) { TreeViewItem itemLevel1 = new TreeViewItem() { Header = "Item Level 1" }; itemLevel1.Items.Add(new TreeViewItem()); rootItem.Items.Add(itemLevel1); } treeView.Items.Add(rootItem); } private void TreeView_CleanUpVirtualizedItem(object sender, CleanUpVirtualizedItemEventArgs e) { } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload