0

I am using a listview similar to the following:

<ListView Margin="10" Name="myListView">
 <ListView.ItemTemplate>
       <DataTemplate>
            <WrapPanel>
                <TextBlock Text="Name: " />
                <TextBlock Text="{Binding Name}" FontWeight="Bold" />
                </WrapPanel>
        </DataTemplate>
 </ListView.ItemTemplate>

I am creating a listing of all files in a directory; a potentially very large number. The loading of the data-set is not in question here; I am preprocessing the data (loading from file, generating a temporary List<>, sorting, etc.) so IO performance is not an issue here.

With my prepopulated List<> object I then do a simple foreach and add:

private async Task AddItemsToList()
{
    foreach(MyObject item in List<MyObject>)
    {
        myListView.Add(item)
    }
}

The above is a mock up, however my code is the same.

When processing this foreach the UI does not update as each item is added. It is displayed as one large chunk once the foreach is complete. AddItemsToList() is not awaited.

I have read a few articles (particularly this) and am under the impression that UWP should automatically incrementally load and utilise placeholders.

Any suggestions would be much appreciated!

Andrew,

Note: I am aware UI Virtualisation would be ideal for excessive data sets (>10,000 items?) as described here.

1
  • Maybe a sample project with sample data for not working part. And yes it is recommended using UI Virtualization for large data sets. Commented Jul 11, 2016 at 12:55

1 Answer 1

0

Have you tried to use MVVM and an ObservableCollection?, and add items directly in the ObservablCollection after reading them from file. Also make sure your reading and processing is async

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Alex. Sorry I didn't post the code behind the ListView. the "listview.xaml.cs" backing does implement an ObservableCollection. Unfortunately I cannot add directly as I do some 'processing' to the data (summing, reordering, tagging, etc.) that requires analysis of the full data set. I figured it was faster/easier not to modify the UI multiple times. The file IO/processing is all async.
You should add the source in Model's List and when the user view then you show from Model.Use MVVM and add the user view number.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.