I am having the Scrollview as following. Now what my scenario is, Initially the scrollviewr will display 10 items. When the scrollbar reaches the 10th item I need some functionality to be implemented. Now the problem is I am unable to to recognize when the scrollbar is reaching the last item. I tried to use the ScrollChanged
event with the vertical offsets but that seems to be not working. Is there any way to achieve this.
<ScrollViewer x:Name="ChatListScrollViewer" Background="#ffffff" Grid.Column="0" ScrollChanged="ChatListScrolled" Focusable="False">
<VirtualizingStackPanel VerticalAlignment="Stretch">
<ItemsControl VirtualizingStackPanel.VirtualizationMode="Recycling" Background="White" x:Name="MessageList" ItemsSource="{Binding Source={StaticResource ChatList}}" Focusable="False" BorderBrush="Transparent" BorderThickness="0" HorizontalAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Hidden" x:FieldModifier="public">
<ItemsControl.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<!-- Code -->
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ItemsControl.GroupStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0">
<!-- Code -->
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</VirtualizingStackPanel>
</ScrollViewer>
EDIT: The scrolling is from bottom to up for my scenario. This is How to find that ScrollViewer is scrolled to the end in WPF? useful to detect the last item of the when the scrolling is downwards. In my scenario, its a like chat application. When the scrollbar is scrolled towards up, and reaches the last messages I need to have retrieve some more data .