Home ยป c# ยป c# – WPF virtualization not working in my project-Exceptionshub

c# – WPF virtualization not working in my project-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment

Questions:

I have problem that virtualization is not working in my project and i’m going crazy ๐Ÿ™‚

I have try simple example in new project and virtualization is working. Also in my project i create simple window with the same code as demo example. Now does anyone have idea what could be wrong in my project are there any settings or what?

public WindowTest()
{
    InitializeComponent();

    for (int i = 0; i < 10000; i++)
    {
        ListBoxWithVirtualization.Items.Add("Item - " + i.ToString());
    }
}
<ListView Name="ListBoxWithVirtualization"   Height="100" Margin="5"
          VirtualizingStackPanel.IsVirtualizing="True"
          VirtualizingStackPanel.VirtualizationMode="Recycling" />

In live visual tree i have notice one difference (Rectangle)which you can se in attached images.
Working
Here is no rectangle visible

How to&Answers: