When would the ItemContainerGenerator.Status enumeration return GeneratorStatus.Error?
When would the ItemContainerGenerator.Status
enumeration return GeneratorStatus.Error
in WPF? Has anyone encountered such a situat开发者_Go百科ion? Just wondering, as I mainly work in Silverlight and the GeneratorStatus
doesn't exist there.
the ItemContainerGenerator
(if used for example in a ListBox) will create a ListBoxItem
for each data item the ListBox
is bound to.
The standard ItemContainerGenerator
in PresentationFramework
has an private class called 'Generator
'. When this class is instantiated by the ItemContainerGenerator
it sets the ItemContainerGenerator
class's Status as GeneratorStatus.GeneratingContainers
, then when the ItemContainerGenerator
calls Dispose
on the Generator
instance, the Generator
class sets the ItemContainerGenerator
status to GeneratorStatus.ContainersGenerated
.
GeneratorStatus.Error
is never used in the standard implmentation, but if your rolling your own ItemsControl
, you can roll your own ItemContainerGenerator
and maybe use the error status in your code.
精彩评论