WPF ListBox SelectedItem有时不可见(滚动不同步)

Dan*_*rik 8 wpf listbox

我有一个填充了30,000个元素的列表框

<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" />
Run Code Online (Sandbox Code Playgroud)

我正在跟踪用户点击项目的历史记录

我有2个按钮上一个.接下来,这些按钮允许用户在历史记录中前后移动.

上一页.和Next按钮修改ListBox的SelectedItem属性

如果用户从ListBox中选择彼此非常分开的随机项(例如,用户选择列表顶部的一些项目和列表底部的几个项目),则会出现问题.

上一页.和Next按钮更改SelectedItem属性,但ListBox不与滚动同步,所选项目不突出显示,大多数时间对用户不可见,因为它在ListBox的可见项目区域之外.

有没有办法让ListBox正确显示当前选中的项目?

谢谢.

Ken*_*art 23

_listBox.ScrollIntoView(_listBox.SelectedItem);
Run Code Online (Sandbox Code Playgroud)