I\'m facing a similar problem with this question however VirtualizingStackPanel.IsVirtualizing=\"False\"
didn\'t solve my problem. Is there anyone facing the sa
try execute UpdateLayout()
before this.ItemContainerGenerator.ContainerFromItem(item)
Use ItemContainerGenerator.StatusChanged event from you ComboBox like this:
myComboBox.ItemContainerGenerator.StatusChanged += ItemContainerGenerator_StatusChanged;
void ItemContainerGenerator_StatusChanged(object sender, System.EventArgs e)
{
if (myComboBox.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)
{
foreach (var item in myComboBox.Items)
{
var container = (ComboBoxItem)LanguageComboBox.ItemContainerGenerator.ContainerFromItem(item);
}
}
}
As my logic was in the SelectionChanged event, i wondered why the ItemContainerGenerator.ContainerFromItem
method always returned null even if the Listbox.SelectedItem
was not null and even more strange, Virtualisation was turned off! Looking at the ItemContainerGenerator.Status
i saw that it was Primitives.GeneratorStatus.NotStarted
then i added a simple test on ItemContainerGenerator.Status == Primitives.GeneratorStatus.ContainersGenerated
and finally solved it that way and no need to subsribe to the Status_Changed event.