I need to iterate through the VirtualizingStackPanel of a ListBox control to get at the ListBoxItem.RenderSize values. In C# of VB.NET code, how might that be done?
Background:
I'm working with a third party control library in WPF which apparently has bugs (or "features") related to its Measure() algorithms. Instead, it does a very non-standard attached Dependency Property to size one of its frames.
To get around that I'm overriding Measure and supplying my own values to the attached property, but the values are being eaten by intervening values in the visual tree. However, the Items property of my ListBox returns viewmodels, which don't contain sizing info. Neither does the template for the viewmodel, which must auto-size.
ListBox.Itemscollection returnsNothing- Rob PerkinsContainerFromItemwill give you theListBoxItemthat holds an item, provided that the item is contained in the ListBox's Items collection, and that the corresponding ListBoxItem has already been created. Maybe the ListBoxItem has not yet been created due to virtualization. - ClemensListBox. - Rob Perkins