ItemContainerGenerator.ContainerFromItem() returns null while VirtualizingStackPanel.IsVirtualizing=“False”

后端 未结 3 442
清歌不尽
清歌不尽 2021-01-13 13:47

I\'m facing a similar problem with this question however VirtualizingStackPanel.IsVirtualizing=\"False\" didn\'t solve my problem. Is there anyone facing the sa

3条回答
  •  孤街浪徒
    2021-01-13 14:14

    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.

提交回复
热议问题