My controls .ItemContainerGenerator.Status is NotStarted. How do I tell it to start now and wait until it is completed?
You can use
ItemContainerGenerator.StatusChanged
event to handle when status are changed
Bind and show the ItemsControl. The ItemContainerGenerator will start and generate items as part of the data binding cycle.
If you really need to manually start the generator, you may be able to do so by calling IItemContainerGenerator.StartAt. This is an explicit interface implementation so you will need to cast the ItemsControl.ItemContainerGenerator property, e.g. ((IItemContainerGenerator)(listBox.ItemContainerGenerator)).StartAt(...);
. But manually starting the generator is very rarely necessary in application code.
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);
}
}