我很努力使ListView
自动向下滚动到底部,每次将新项目添加到ItemsSource
时。据this post,我所要做的就是使用以下方法:使用WinRT XAML Toolkit
自动滚动到WinRT App中的ListView底部
private void ScrollToBottom()
{
var scrollViewer = MyListView.GetFirstDescendantOfType<ScrollViewer>();
scrollViewer.ScrollToVerticalOffset(scrollViewer.ScrollableHeight);
}
。但它没有效果我每次添加或删除ListView的项目集合中的元素时,都会调用此方法。没有自动滚动。
而在XAML,那么,还有ListView控件:
<ScrollViewer>
<ListView x:Name="LinesListView"
ItemsSource="{Binding Lines}"
ItemTemplate="{StaticResource LineItemTemplate}">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel>
<StackPanel.ChildrenTransitions>
<TransitionCollection>
<EntranceThemeTransition/>
</TransitionCollection>
</StackPanel.ChildrenTransitions>
</StackPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
</ScrollViewer>
有,另一方面另一种解决方案,我上面提供的同一链路上,但它不显示列表视图项动画即使我尝试在XAML中指定它。
我在这里错过了什么?
任何建议非常感谢,谢谢。
你知道最新的listview是什么吗? –
是的,他们都OK,绑定工作正常,它只是...不向下滚动,这就是为什么我不知道和如何解决它... – VasileF
我想你可能会在项目之前滚动完全添加和创建。您可能能够创建一个自定义的ListView来覆盖OnItemsChanged,以确保它在项目进入后滚动。 –