ListView max number of rows ? RRS feed

  • Question

  • Windows 8.1, Windows Store App, XAML/C#
    Trying to learn and understand.

    Adding items to a ListView, when passing 41943 items (silly of course, but just for experimenting) the new ones are not rendered.

    The "funny" thing is that if I position the cursor at row 41943 and use mouse scroll wheel, then I can se the new rows, but only a short glimpse before they disappear again and only with scrollwheel, clicking scrollbar doesn't make them visible.

    What is going on here ?

    Friday, August 22, 2014 7:29 PM

All replies

  • Hi EuroEager,

    As I know you have to enable Virtualization with ListView, see this for more information: Using virtualization with a list or grid, then you should be able to see the row after 41943 will display without any problem.


    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, August 25, 2014 11:26 AM
  • Hi James

    Have you actually "tested" your answer ?
    Do I need to enable virtualization ?
    I use a ListView inside a Grid inside a Page.
    The ListView contains an ItemTemplate with a StackPanel containing a few TextBlocks (stacked horizontally).
    I think this enables virtualization by itself.

    The ItemsSource is bound via Page binding to an ObservableCollection (see below).

    My ViewModel (for which the Page is bound to) contains an ObservableCollection of instances of a certain model class.

    I simply add 100000 instances to this collection which in turn updates the ListView (or almost half of it).

    And why should virtualization matter at all ? I thought that has only to with performance and resource usage.

    Anyway, if not virtualized, I thought all items should definitely be shown (after a while and perhaps slow scrolling though).

    I tried to change the ListView to a ListBox, otherwise identical, same ItemTemplate and all, then it works exactly as I expected (all 100000 items are shown immediately when I scroll).
    Why this difference ?
    (your referenced document states clearly that there are no difference between the two regarding virtualization).

    And what is magic about the number 41943 (or 41944) ?

    Monday, August 25, 2014 6:40 PM
  • Hi there, 

    Like MSDN states:

    "As long as the new panel supports UI virtualization, the control continues to perform this optimization for free. Standard virtualizing panels include ItemsWrapGrid and ItemsStackPanel. Replacing the default panel in anItemsControl with non-virtualizing panels (VariableSizedWrapGridWrapGrid, and StackPanel) disables UI virtualization for that control."

    Developers can customize the template of a ListView control as they wish, so the whether the app still keeps UI virtualization still strongly depends on how this app is writing.



    Monday, September 1, 2014 8:47 AM
  • Thanks, Ok, but as I said earlier, I think UI virtualization is used default.
    No data virtualization (objects created and added directly to an ObservableCollection).

    Why 41943 ?
    Why no problem with ListBox instead of ListView.

    I cannot see that references to virtualization explains my observations at all.

    Monday, September 1, 2014 9:28 PM
  • Is there a simple reproduction sample? with repro steps..
    Wednesday, October 8, 2014 7:28 AM
  • Sure, make a (8.1) store app (I use VS 2013, update 3)

        mc:Ignorable="d" Loaded="Page_Loaded">
            <DataTemplate x:Key="CommonDataTemplate">
                <TextBlock Text="{Binding Row}"/>
        <StackPanel Orientation="Horizontal">
            <ListView MinWidth="500" ItemsSource="{Binding}" ItemTemplate="{StaticResource CommonDataTemplate}"/>
            <ListBox MinWidth="500" ItemsSource="{Binding}" ItemTemplate="{StaticResource CommonDataTemplate}"/>


    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Runtime.InteropServices.WindowsRuntime;
    using Windows.Foundation;
    using Windows.Foundation.Collections;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Controls.Primitives;
    using Windows.UI.Xaml.Data;
    using Windows.UI.Xaml.Input;
    using Windows.UI.Xaml.Media;
    using Windows.UI.Xaml.Navigation;
    // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
    namespace TheStrange41943Rows
        /// <summary>
        /// An empty page that can be used on its own or navigated to within a Frame.
        /// </summary>
        public sealed partial class MainPage : Page
            public MainPage()
            private void Page_Loaded(object sender, RoutedEventArgs e)
                int maxNoOfItems = 100000;
                List<object> myItems = new List<object>(maxNoOfItems);
                foreach (var ix in Enumerable.Range(1, maxNoOfItems))
                    myItems.Add(new { Row = "Row" + ix.ToString("00000") });
                DataContext = myItems;

    Use scroll bar (I haven't tried a touch panel, don't have any) for both controls shows that the ListView is not willing to show more than 41943 rows (except if you use the scroll wheel, then they are shown for a very short time and disappears again) while the ListBox shows them all.

    Please tell me if you want me to upload the project files (and how to do that).

    Sunday, October 12, 2014 12:18 PM
  • I'm having a similar problem (mine stops at 29656 for some reason), was wondering if you figured out a solution!
    Monday, December 22, 2014 4:01 AM
  • No, I didn't figure out a solution.
    It is not that important for me, mostly academic (to me it seems like a bug and bugs tends to show up again under different circumstances which may be more than just academic though).

    Do you have the same funny glimpses when using the scroll wheel ?

    Monday, December 22, 2014 9:04 AM