WPF: control.ItemContainerGenerator.Status NotStarted. How do I say to get started now?

My Controls .ItemContainerGenerator.Status NotStarted. How can I say to start now and wait until it is completed?

+4
source share
3 answers

You might want to start the generator manually if you perform some synchronous operation - I had to generate a representation of the result in order to disable it before placing it on the 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); } } 
+9
source

Bind and show ItemsControl. ItemContainerGenerator will launch and generate items as part of a data binding cycle.

If you really need to manually start the generator, you can do this by calling IItemContainerGenerator.StartAt. This is an explicit implementation of the interface, so you will need to distinguish the ItemsControl.ItemContainerGenerator property, for example. ((IItemContainerGenerator)(listBox.ItemContainerGenerator)).StartAt(...); . But manually starting the generator is very rarely needed in the application code.

+1
source

you can use

 ItemContainerGenerator.StatusChanged 

for processing when changing status

0
source

Source: https://habr.com/ru/post/1304622/


All Articles