---
title: "Slow loading WPF Form."  
description: "Slow loading WPF Form."  
author: "Royce Roy"  
published: 2013-08-16  
updated: 2013-08-17  
canonical: https://www.mindstick.com/forum/1385/slow-loading-wpf-form  
category: "wpf"  
tags: ["wpf"]  
reading_time: 2 minutes  

---

# Slow loading WPF Form.

**Hi Guys**\

I've been [search](https://www.mindstick.com/articles/65368/best-smo-services-company-in-hyderabad-improve-search-rankings) for a solution to a [slow](https://answers.mindstick.com/qa/50237/sometimes-the-web-browser-stops-responding-or-becomes-slow-and-will-show-you-the-message-that-the-web-browser-was-crashed-what-can-be-the-risks) loading [wpf](https://www.mindstick.com/forum/304/wpf) form. It seems that virtualization should help me out, but I [must](https://www.mindstick.com/articles/12978/top-reasons-why-every-magento-ecommerce-store-must-opt-for-mobile-app) be [missing](https://answers.mindstick.com/qa/52138/international-missing-children-s-day-2019-was-observed-on) something.

I'm loading 35k [orders](https://answers.mindstick.com/qa/43206/what-were-the-fundamental-orders-of-connecticut-and-who-wrote-them) and it takes 15 seconds to load. My guess is that virtualization isn't actually working for me.

```
<UserControl x:Class="IntTranWin.Modules.Orders.OrderSummary.OrdersSummaryView"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300">  <ListView BorderThickness="0" Width="Auto" ItemsSource="{Binding Path=Orders.Items}" AlternationCount="2"            IsSynchronizedWithCurrentItem="True" VirtualizingStackPanel.IsVirtualizing="True"            VirtualizingStackPanel.VirtualizationMode="Recycling" ScrollViewer.IsDeferredScrollingEnabled="True">    <ListView.ItemsPanel>      <ItemsPanelTemplate>        <VirtualizingStackPanel />      </ItemsPanelTemplate>    </ListView.ItemsPanel>    <ListView.View>      <GridView AllowsColumnReorder="true" ColumnHeaderToolTip="Orders">        <GridViewColumn Header="Number" DisplayMemberBinding="{Binding Path=OrderNumber}" Width="65" />      </GridView>    </ListView.View>  </ListView></UserControl>
```

## Thanks

## Replies

### Reply by shreesh chandra shukla

Hi!

There wasn't really anything wrong with wpf I provided. The problem was in a styling of ScrollViewer for the GridView which disabled virtualization.

```
<Style x:Key="{x:Static
GridView.GridViewScrollViewerStyleKey}" TargetType="{x:Type
ScrollViewer}"><Setter Property="Template">  <Setter.Value>   
<ControlTemplate TargetType="{x:Type ScrollViewer}">      <Grid
Background="{TemplateBinding Background}">       
<Grid.ColumnDefinitions>         
<ColumnDefinition Width="*" />         
<ColumnDefinition Width="Auto" />       
</Grid.ColumnDefinitions>       
<Grid.RowDefinitions>         
<RowDefinition Height="*" />         
<RowDefinition Height="Auto" />       
</Grid.RowDefinitions>         <DockPanel
Margin="{TemplateBinding Padding}">         
<ScrollViewer DockPanel.Dock="Top"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden"                       
Focusable="false">            <Border
CornerRadius="4" Background="{StaticResource
DefaultedBorderBrush}" Padding="4"
Margin="0,4,0,4">             
<GridViewHeaderRowPresenter Margin="2,0,2,0"                                         
Columns="{Binding
Path=TemplatedParent.View.Columns,RelativeSource={RelativeSource TemplatedParent}}"                                         
ColumnHeaderContainerStyle="{Binding
Path=TemplatedParent.View.ColumnHeaderContainerStyle,RelativeSource={RelativeSource
TemplatedParent}}"                                         
ColumnHeaderTemplate="{Binding
Path=TemplatedParent.View.ColumnHeaderTemplate,RelativeSource={RelativeSource
TemplatedParent}}"                                         
ColumnHeaderTemplateSelector="{Binding
Path=TemplatedParent.View.ColumnHeaderTemplateSelector,RelativeSource={RelativeSource
TemplatedParent}}"                                         
AllowsColumnReorder="{Binding
Path=TemplatedParent.View.AllowsColumnReorder,RelativeSource={RelativeSource
TemplatedParent}}"                                         
ColumnHeaderContextMenu="{Binding
Path=TemplatedParent.View.ColumnHeaderContextMenu,RelativeSource={RelativeSource
TemplatedParent}}"                                         
ColumnHeaderToolTip="{Binding
Path=TemplatedParent.View.ColumnHeaderToolTip,RelativeSource={RelativeSource
TemplatedParent}}"                                         
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
/>           
</Border>          
</ScrollViewer>          
<ScrollContentPresenter Name="PART_ScrollContentPresenter"
KeyboardNavigation.DirectionalNavigation="Local" />       
</DockPanel>         <ScrollBar
Name="PART_HorizontalScrollBar" Orientation="Horizontal"
Grid.Row="1"                  
Maximum="{TemplateBinding ScrollableWidth}"
ViewportSize="{TemplateBinding ViewportWidth}"                  
Value="{TemplateBinding HorizontalOffset}"
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
/>         <ScrollBar
Name="PART_VerticalScrollBar" Grid.Column="1"
Maximum="{TemplateBinding ScrollableHeight}"                  
ViewportSize="{TemplateBinding ViewportHeight}"
Value="{TemplateBinding VerticalOffset}"                  
Visibility="{TemplateBinding
ComputedVerticalScrollBarVisibility}" />       </Grid>   
</ControlTemplate>  </Setter.Value></Setter> 
```

I hope it will work fine.


---

Original Source: https://www.mindstick.com/forum/1385/slow-loading-wpf-form

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
