Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF: control.ItemContainerGenerator.Status is NotStarted. How do I tell it to start now?

Tags:

wpf

My controls .ItemContainerGenerator.Status is NotStarted. How do I tell it to start now and wait until it is completed?

like image 642
Jonathan Allen Avatar asked Dec 29 '22 22:12

Jonathan Allen


1 Answers

You may want to start the generator manually if you doing some syncronous operation - I had to generate the result view to meassure it before chunking it up on pages.

   IItemContainerGenerator generator = (child as ListContent).ItemContainerGenerator;
   GeneratorPosition position = generator.GeneratorPositionFromIndex(0);
   using (generator.StartAt(position, GeneratorDirection.Forward,true))
   {
                        foreach (object o in (child as ListContent).Items)
                        {
                            DependencyObject dp = generator.GenerateNext();
                            generator.PrepareItemContainer(dp);
                        }
   }
like image 195
Hans Karlsen Avatar answered May 27 '23 18:05

Hans Karlsen