简体   繁体   English

在WP7 Silverlight中的ListView中滚动不起作用

[英]Scroll in ListView in WP7 Silverlight not working

In the following code: 在下面的代码中:

listBox1.SelectedIndex = SelectedIndex;
if (SelectedIndex >= 0)
    listBox1.ScrollIntoView(listBox1.SelectedItem);

The listbox won't actually scroll. 列表框实际上不会滚动。 I've stepped through to make sure SelectedItem is not null, but the list continues to remain at the top despite everything... Am I missing something? 我已逐步完成操作,以确保SelectedItem不为null,但无论如何,该列表仍将保持在顶部...我是否缺少某些东西?

Did you consider this note on MSDN : 您是否在MSDN上考虑了此说明:

When the contents of the ItemsSource collection changes, particularly if many items are added to or removed from the collection, you may need to call UpdateLayout prior to calling ScrollIntoView for the specified item to scroll into the viewport. 当ItemsSource集合的内容发生更改时,尤其是在向集合中添加或删除了许多项目时,可能需要在调用ScrollIntoView之前调用UpdateLayout,以使指定的项目滚动到视口中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM