0

I have a WPF listbox. The items are bound to the listbox.

When I select a few items at the top of the listbox and scroll down to the bottom of the listbox to select other items, the items that were earlier selected at the top are getting unselected.

I am finding this behavior with selection mode set to Extended as well as Multiple. Please advice.

  • did you set ScrollViewer.CanContentScroll=True? that might do it... – Rachel Gallen Jan 21 '13 at 18:48
  • 1
    Is it a result of virtualization? Perhaps the items at the top are being unloaded as they scroll out of view. Check [this answer](http://stackoverflow.com/questions/2143655/wpf-list-boxes-and-virtualization) for information about listbox virtualization. – Brian S Jan 21 '13 at 18:58
  • I tried setting ScrollViewer.CanContentScroll=True, but the behavior is still same. Sometimes, I find that a few of the selected items on the top remain selected, while others are unselected. It was a Virtualization problem. On setting ScrollViewer.CanContentScroll=False, the Virtualization is turned off and it works as expected. However, this can impact the performance a little. Thanks a lot !! – user1174134 Jan 21 '13 at 19:29

2 Answers2

0

Try turning off virtualization

<ListBox VirtualizingStackPanel.IsVirtualizing="False" 
                       ItemsSource="{Binding XPath=Team}" 
                       ItemTemplate="{DynamicResource NameDataStyle}"/> 
paparazzo
  • 44,497
  • 23
  • 105
  • 176
0

FYI - For anybody working with Silverlight who finds this answer, try using this:

VirtualizingStackPanel.VirtualizationMode="Standard"
David
  • 1