locked
WinRT bug report - ListView with large dataset being clipped

    General discussion

  • I think I've found a bug in the Windows store (WinRT 8.1) version of the ListView (I've not tried on windows phone).

    When I create a page with a ListView and bind it to an ItemsSource with many items I find that as I start to scroll through these items the rendered ListViewItems will suddenly disappear as if they are hidden behind another control.

    I have created a simple example to demonstrate the issue.  Create a blank Universal app and replace the contents of the MainPage.xaml and MainPage.xaml.cs of the Win8 app with the code below.  Build and run the code and use the mouse to drag the scrollbar handle down to item 41351 and you will see that all items after that are not displayed.

    This looks like a bug to me but what does everyone else think?

    Does anyone know of a work-around?

    MainPage.xaml

    <Page
        x:Class="WinRTListViewClipping.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:WinRTListViewClipping"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        x:Name="Root">
    
      <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <ListView ItemsSource="{Binding Items}"/>
      </Grid>
    </Page>
    

    MainPage.xaml.cs

    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 WinRTListViewClipping
    {
        /// <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 static readonly DependencyProperty ItemsProperty =
              DependencyProperty.Register(
                  "Items",
                  typeof(List<string>),
                  typeof(MainPage),
                  new PropertyMetadata(new List<string>()));
    
          public List<string> Items
          {
            get { return (List<string>)GetValue(ItemsProperty); }
            set { SetValue(ItemsProperty, value); }
          }
    
          public MainPage()
          {
            DataContext = this;
            for (int idx = 0; idx < 100000; idx++)
              Items.Add("Item: " + idx.ToString());
    
            this.InitializeComponent();
          }
        }
    }
    

    Sunday, February 8, 2015 4:25 PM

All replies

  • I've noticed an annoying feature of the WinRT ListView and I've created a simple example to demonstrate the problem.

    With the ListView I'm experiencing unwanted clipping where a lot of items are displayed.  In the following example the ListView works fine on the first 41350 items but after that you cannot see them.  They still seem to be there because you can move the focus using the cursor keys, but you just cannot see them.

    Does anyone know why this happens and if there's a work around or fix for it?

    Windows Store Example - XAML

    <Page
        x:Class="WinRTListViewClipping.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:WinRTListViewClipping"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        x:Name="Root">
    
      <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <ListView ItemsSource="{Binding Items}"/>
      </Grid>
    </Page>
    

    Windows Store Example - Code Behind

    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 WinRTListViewClipping
    {
        /// <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 static readonly DependencyProperty ItemsProperty =
              DependencyProperty.Register(
                  "Items",
                  typeof(List<string>),
                  typeof(MainPage),
                  new PropertyMetadata(new List<string>()));
    
          public List<string> Items
          {
            get { return (List<string>)GetValue(ItemsProperty); }
            set { SetValue(ItemsProperty, value); }
          }
    
          public MainPage()
          {
            DataContext = this;
            for (int idx = 0; idx < 100000; idx++)
              Items.Add("Item: " + idx.ToString());
    
            this.InitializeComponent();
          }
        }
    }
    

    Saturday, February 7, 2015 9:21 PM
  • Has anyone got any idea's on this?  It looks like it might be a WinRT bug to me.
    Sunday, February 8, 2015 8:23 AM
  • Does anyone know how I can report this as a bug to Microsoft?
    Sunday, February 8, 2015 12:25 PM
  • Hi,

    That's a common issue in ListView.  When the collection is very large, performance can be degraded when displaying or manipulating the collection. To improve performance with large data sets, you can use virtualization. For more inforamtion, please refer to the link:

    https://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh780657.aspx

    To solve the problem, you must use a data source that implements ISupportIncrementalLoading. When you use incremental data virtualization with a ListView or GridView, you can use these members to control data loading: DataFetchSize, IncrementalLoadingThreshold, IncrementalLoadingTrigger, LoadMoreItemsAsync.

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

    Monday, February 9, 2015 8:45 AM
  • Hi Anne,

    My example app was just to demonstrate the issue.  I have a much more complex app that was suffering the same issue.

    I thought that it was virtualising the control because I had code in it for data virtualisation which was working fine.  The problem was that this code has been ported from WPF and I had created the ListView without changing the ItemsPanel to a VirtualizingStackPanel.  As soon as I did that everything worked as it should.

    Thanks very much for your post.  Virtualisation was definitely the issue.

    Monday, February 9, 2015 6:03 PM