Answered by:
LoadMoreItemsAsync is called a lot of times at startup even if ItemWidth and ItemHeight are set

Question
-
Hi,
since Windows 8.1 Preview forum has been closed, I post here my previous question:
It seems these issues are still present inWindows 8.1 final version.
Any workaround?
Tuesday, October 22, 2013 4:11 AM
Answers
-
The reason it is jumping back to the beginning is because you are sending the Reset Event(see ExtendedObservableCollection.cs):
public void Add(IEnumerable<T> items)
{
if (items != null)
{
this.SuspendCollectionChangeNotification();
int index = base.Count;
try
{
foreach (var i in items)
{
base.InsertItem(base.Count, i);
}
}
finally
{
this.ResumeCollectionChangeNotification();
var arg = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset);
this.OnCollectionChanged(arg);
}
}
}
If you want to keep the position then you need to raise as many Add events as many items is being loaded.
Bret Bentzinger (MSFT) @awehellyeah
- Marked as answer by OasisLiveForever Thursday, October 24, 2013 4:02 AM
Wednesday, October 23, 2013 10:02 PMModerator
All replies
-
This issue should be resolved in 8.1. Are you running 8.1 RTM, and Visual Studio 2013 RTM? Also, are you using the same repro?
Bret Bentzinger (MSFT) @awehellyeah
Tuesday, October 22, 2013 6:12 PMModerator -
Hi,
you can find a sample application that reproduce the problem here:
https://skydrive.live.com/redir?resid=9254CCAFCE7EE400!1733&authkey=!AIFRpAqDpjMsFSQ
In the zip file I uploaded to SkyDrive you can find two folders:
- TestIncrementalLoading that contains the Windows 8.1 Preview App
- TestIncrementalLoadingServices that contains the ASP.NET MVC server side applicationSince I'm using Express version of VS 2013, I cannot have the two projects in the same solution so you have to open it separately without using the solution file TestIncrementalLoadin.sln.
There were two issues in Windows 8.1 Preview:
1) LoadMoreItemsAsync was called a lot of times at startup (the first time with count = 1, the second time with count = 1, the third time with count = page size), even if I specify ItemWidth and ItemHeight in ItemsWrapGrid container.
2) Items were scrolled to the beginning of the list after each incremental load.
The first issue seems to be fixed but the second one is still present: each time LoadMoreItemsAsync is called, the list is scrolled to the begin and this is very annoying.
I found also another issue that I'm not able to reproduce in the sample application but in my real application: when I start another Windows Store app and then I switch back to my app before the app is suspended (swiping from the left corner and selecting the app), all items in the list disappears.
Wednesday, October 23, 2013 3:41 AM -
The reason it is jumping back to the beginning is because you are sending the Reset Event(see ExtendedObservableCollection.cs):
public void Add(IEnumerable<T> items)
{
if (items != null)
{
this.SuspendCollectionChangeNotification();
int index = base.Count;
try
{
foreach (var i in items)
{
base.InsertItem(base.Count, i);
}
}
finally
{
this.ResumeCollectionChangeNotification();
var arg = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset);
this.OnCollectionChanged(arg);
}
}
}
If you want to keep the position then you need to raise as many Add events as many items is being loaded.
Bret Bentzinger (MSFT) @awehellyeah
- Marked as answer by OasisLiveForever Thursday, October 24, 2013 4:02 AM
Wednesday, October 23, 2013 10:02 PMModerator -
Hi,
I tried the standard ObservableCollection instead of my custom ExtendedObservableCollection and it works.
In Windows 8 my custom ExtendedObservableCollection was working and I'm porting it to Windows 8.1 but maybe something is changed in GridView and ListView.
So I'll go with ObservableCollection.Thank you very much!
Thursday, October 24, 2013 4:02 AM