There is a listbox and you need to load, say, 1000 values. If I load in DataGrid or DataView, then everything is loaded instantly and does not "lag". And when I load from the database to the ListBox, I have at best a second delay while it unloads everything into memory. As far as I understand, in the list box, he immediately unloads everything into memory [although with current processors it is not a problem, in short, he does something else that loads the program], and in the grid, only the visible area plus a little more.

In the book of Matthew Macdonald on WPF 4.0 it is written about virtualization and after that the listbox works fine. In general, I did it, but I still have the same problem. Can someone come across this?

  • In general, I took the Teletik component, and there the box box is normal .... I don’t float, why didn’t it work there .... - Rakzin Roman

2 answers 2

If there is something like BeginUpdate, EndUpdate (they may be called differently), try calling the first before starting the change and the second after all the changes.

    Hello.

    I consider myself a pro in the bottlenecks of the code relating to the interface. Faced with such a problem. The most likely thing is that the wrong xaml is used in the source files of the markup. Our "pros" do not check the speed of work, only to be beautiful.

    Everything is solved simply, you need to adjust the style Template. In the place where there is such (in particular in ListBox):

     <StackPanel IsItemsHost="true" ... /> 

    Need to do right:

     <ItemsPresenter ... выравнивание и т.п. ... /> 

    By the way, it not only speeds up the work, but also allows you to correctly display your own ListBoxItem styles. PS I myself have tested, so I don’t even know why they use the IsItemsHost panel property instead of the normal ItemPresenter