Asked by:
ScrollView ViewChanged not raised when inital content is not out of bound

Question
-
This is a continuing question to my previous question: http://social.msdn.microsoft.com/Forums/windowsapps/en-US/81be65e8-7aaf-4db2-87b4-c658e7b0bbfb/scrollview-viewchanged-not-raised
ViewChanged event is not fired if the GridView doesn't have much content initially, for example, just load one group initially by changing the MainPage constructor to:
public MainPage() { this.InitializeComponent(); ObservableCollection<GroupItem> initData = new ObservableCollection<GroupItem>(); for (int i = 0; i < 1; i++) { initData.Add(new GroupItem()); } itemsViewSource.Source = new ItemsIncrementalLoader(initData); }
Since my ultimate goal is to implement incremental loading, really need to detect the scroll left and scroll right action.
How to achieve this? Thanks a lot!
ChunmiaoTuesday, August 13, 2013 6:10 PM
All replies
-
Hi,
For Incremental Loading set the ItemsPanel of the GridView to VirtualizingStackPanel. It is intended for that purpose. It automatically implements incremental loading by virtualization.
<GridView Width="346" x:Name="List" Grid.Column="1" Grid.Row="1"> <GridView.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel VirtualizationMode="Recycling"/> </ItemsPanelTemplate> </GridView.ItemsPanel> </GridView/>
srithar
Tuesday, August 13, 2013 7:00 PM -
Srithar,
Thanks for your reply. But in my case, the GridView is grouped. Incremental loading doesn't work naturally.
Searched for other threads, and seems the best shot is to implement the ViewChanged event, which leads to the above question.
Thanks.
Tuesday, August 13, 2013 7:11 PM -
Conceptually, the ViewChanged event will fire if there is a change to the Scrollviewer's HorizontalOffset/VerticalOffset/ZoomFactor. When the content fits within the viewing area, there is nothing to scroll to and hence ViewChanged events will not be fired.
Harini Kannan | Program Manager, XAML
Wednesday, August 14, 2013 2:03 AM -
Thanks Harini.
How to get the swipe action then? I need the swipe, or better scroll bar, action to load more items.
Thanks a lot in advance!
Wednesday, August 14, 2013 3:56 AM