I am struggling to make a ListView
automatically scroll down to bottom each time a new item is added to the ItemsSource
. According to this post, all I have to do is to use the following :
private void ScrollToBottom()
{
var scrollViewer = MyListView.GetFirstDescendantOfType<ScrollViewer>();
scrollViewer.ScrollToVerticalOffset(scrollViewer.ScrollableHeight);
}
using the WinRT XAML Toolkit
. But it has no effect I am calling this method each time I add or remove an element from the items collection of the ListView. No auto-scrolling though.
And in XAML, well, there's the 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>
There is on the other hand another solution, on the same link I have provided above, but it doesn't show listview items animation even if I try to specify it in XAML.
What am I missing here?
Any suggestions are greatly appreciated, thank you.