Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

ListBox SelectedItem sometimes is not visible (scrolling is out of sync)

$
0
0

Hello,

I have a Listbox that is filled with 30,000 elements

<ListBox Name="lbWordlist" 
                 Grid.Row="1" Margin="10"
                 ItemsSource="{Binding Source={StaticResource WordListViewSource}}" 
                 SelectedItem="{Binding Source={StaticResource MainViewModel}, Path=SelectedArticle}"
                 IsSynchronizedWithCurrentItem="True"
                 SelectionChanged="lbWordlist_SelectionChanged" />

I'm tracking history of user clicking items

I have 2 buttons Prev. and Next, these buttons allow user to go back and forward in history.

Prev. and Next button modify SelectedItem property of ListBox

The problem comes up, if user selects random items from ListBox that are very apart from each other (for example user selected some items on top of the list and few items in the bottom of the list).

Prev. and Next button change SelectedItem property, but ListBox is not synced with scroll, selected item is not highlighted and most of the times is not visible to user, as it's outside of ListBox's visible items area.

Is there any way to make ListBox correctly show currently selected item?

Thank You.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>