locked
Data Grid takes Time to load RRS feed

  • General discussion

  • Hi All,

    We are working on a Windows 8 (XAML + C#) application where we are loading a grid with 100 content (mostly names). Currently the data grid takes a lot of time to load and it is not giving a good user friendly UI.

    The collection might have records varying from 100 to 10,000. At any given point of time we are loading only 100 records in the Grid.

     

    The code is as follows:

      prgBar.Visibility = Visibility.Visible;
    
       _currentCount -= 200;   GrdViewWord.ItemsSource = _collection.Skip(_currentCount).Take(100);   lstWordSnapped.ItemsSource = _collection.Skip(_currentCount).Take(100);
    _currentCount += 100;         
    _currentPage--;
    txtTotalCount.Text = _currentPage + "/ " + _totalPages;
    prgBar.Visibility = Visibility.Collapsed;
    _directions = SortDirections.Desending;
    

     

    On the XAML part this is the code we have put on.

     <ScrollViewer x:Name="scrollViewer" ZoomMode="Disabled" VerticalScrollMode="Disabled" Grid.Row="1" VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Auto" Margin="0">
    <GridView x:Name="GrdViewWord" SelectionMode="Multiple" ItemContainerStyle="{StaticResource
    GridViewItemStyle}" ItemClick="GrdViewWord_ItemClick" SelectionChanged="GrdViewWord_SelectionChanged" Background="#FFE2E2E2" Height="396" VerticalAlignment="Top">
     <GridView.ItemsPanel>                    
    <ItemsPanelTemplate>                    
    <WrapGrid Orientation="Vertical" MaximumRowsOrColumns="10" Background="{Binding BG}"/>                
    </ItemsPanelTemplate>
                        </GridView.ItemsPanel>
                        <GridView.ItemTemplate>    
    <DataTemplate>                          
    <StackPanel Orientation="Horizontal">
    <TextBlock Text="{Binding WordName}" Tag="{Binding WordID}" FontFamily="Segoe UI" FontSize="22.667" Margin="5,5,0,0" Foreground="Black" HorizontalAlignment="Left" Height="40" Padding="0"/>               
    </StackPanel>
    </DataTemplate>
     </GridView.ItemTemplate>  </GridView>
      </ScrollViewer>


     

    Now the application is taking 3-5 seconds to load 100 records in the datagrid.

    Please let me know if we can resolve this with any work around.


    Thanks in advance


    Regards
    Biju Melayil




    Regards Biju S Melayil

    • Changed type Jamles HezModerator Monday, June 3, 2013 8:29 AM already got answer by another thread
    Tuesday, May 28, 2013 12:40 PM

All replies

  • The wrapgrid used in your itemspaneltemplate doesn't support virtualisation so it's forcing all 100 items to be added to the visualtree before displaying.

    If you don't need the wrapgrid functionality you could try replacing it with a stackpanel which does support virtualisation.


    British Airways Inspiration App & rara music

    Tuesday, May 28, 2013 12:51 PM
  • Thanks Flexman.

    I have changed the code as follows:

     
     <ScrollViewer x:Name="scrollViewer" ZoomMode="Disabled" VerticalScrollMode="Disabled" Grid.Row="1" VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Auto" Margin="0"> 
    <GridView x:Name="GrdViewWord" SelectionMode="Multiple" ItemContainerStyle="{StaticResource GridViewItemStyle}" ItemClick="GrdViewWord_ItemClick" SelectionChanged="GrdViewWord_SelectionChanged" Background="#FFE2E2E2" Height="396" VerticalAlignment="Top" > 
    <GridView.ItemTemplate>
    <DataTemplate>
    <StackPanel Orientation="Horizontal" >
    <TextBlock Text="{Binding WordName}" Tag="{Binding WordID}" FontFamily="Segoe UI" FontSize="22.667" Margin="5,5,0,0" Foreground="Black" HorizontalAlignment="Left" Height="40" Padding="0"/>                            
    </StackPanel>                        
    </DataTemplate>                    
    </GridView.ItemTemplate>                
    </GridView>
    </ScrollViewer>

    But i am getting the same result.


    Cheers
    Biju


    Regards Biju S Melayil

    Tuesday, May 28, 2013 1:08 PM
  • Sorry, missed the fact you had wrapped your gridview in a scrollviewer, this will also impact virtualisation.

    Remove the outer scrollviewer as the gridview internally uses a scrollviewer which will give the same effect you are after.


    British Airways Inspiration App & rara music

    Wednesday, May 29, 2013 10:22 AM
  • Hi Flex,

    we have removed the scroll viewer and tried and it provide the same error. Now the grid has been changed to semantic view and we are getting the loading issue which i have raised in a new link.

    http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/076d3543-cc11-46cc-aa4e-f7e08f437eb4

    Our aim is simple, to load more than 5000 Records in a data grid with semantic zoom which is giving us the issue

    Thanks for your time

    Cheers

    Biju


    Regards Biju S Melayil

    Wednesday, May 29, 2013 10:33 AM