ListBox ItemContainerGenerator returns null even when listbox has items?

Virtualization means that listboxitems only gets generated if visible. So you can not use the ItemContainerGenerator to get non generated (non visible) listbox items.

Virtualization means that listboxitems only gets generated if visible. So you can not use the ItemContainerGenerator to get non generated (non visible) listbox items. Do you really need the listbox item directly?

It looks like your listbox is data driven so work with the data directly.

I was just going to put an answer the same thing you said. :) .. Well I actually need the item for providing Custom Drag~Drop support. – Rohit Kandhal Apr 20 at 13:37 Although i'm able to fix the above problem but got struck in one more issue.In case virtualization is true, ScrollViewer - ViewPortHeight comes to 4.0 (However listbox's actual width is too much greater than this).

Is there any work around for this? – Rohit Kandhal Apr 20 at 13:38 Are you saying you want to know the total height of all listbox items? If the list box is virtualized then you will not know since non visible items are not generated.

If all items have the same height then you can just get height for 1 item * number of items. – Wallstreet Programmer Apr 21 at 13:02 Actually I need type of ListBoxItemContainer. Earlier I tried getting first item i.e.

ItemContainerGenerator. ContainerFromIndex(0) but as first element is not generated (bcz of virtualization) it was null. How can I excess the element which is currently displayed.

Although i'm able to do this by type casting ItemsContainer to listbox and then ContainerFromIndex(listbox's selectedIndex - 1); .. It works but I need a generic approach as ItemsControl doesn't have selectedIndex. – Rohit Kandhal Apr 21 at 14:24.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions