I have tried using both a customized DataGrid as well as the stock one in WPF. I have tried populating them manually as well as through bindings. In both cases they are sl
I have same problem with bound Data grid, and I notice that in first load it is fast but on secand and next it is slow. So when I add in code
DataGrid.ItemsSource = Nothing
and then TableAdapter.Fill(Mydataset.MyStoredProcedure,....) DataGrid.ItemsSource=Mydataset.MyStoredProcedure
it became very FAST
I was having big issues with 1000 rows, 5 columns where the render time was taking 7-10 seconds, but the solution found at https://www.elegant-software.net/2014/05/performance-of-the-wpf-datagrid.html made the grid load instantly!
<DataGrid
EnableRowVirtualization="True"
EnableColumnVirtualization="True">
I have a Surface Pro 3 on which my datagrid, with about 200 rows and 10 columns, was really slow at scrolling, jerky and hesitant.
I thought it was the network, but it was in fact the graphics card not being able to keep up with - wait for it - a drop shadow effect on the datagrid itself, even though the background of the control was set to a solid colour.
I commented out the effect and it was 4-5 times faster.
Hope this helps.
Well a little bit adding more (i know its very old topic, but still it helps someone)...
I tried
EnableColumnVirtualization="True" VirtualizingPanel.VirtualizationMode="Recycling"
EnableRowVirtualization="True"
for DataGrid(AutoGenerateColumns="True"
) binding to DataTable.DefaultView() and No effect on speed, it was still horrible for Speed as well as for navigation between rows. Than, I came up with solution to set Fixed Height and Width of DataGrid. Additionally I also set
RowHeight="23"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible"
This makes my page fill very fast... Instead of 2 min, now it takes hardly 10-12 seconds.
Hope it helps someone.
Note: I am using .Net 4.5
Are you have:
VirtualizingStackPanel.VirtualizationMode
for a Grid? if not - try to set.One more point, could you bind whole items collection at once instead of adding each item into the grid.Items collection?
In my case I had a problem with DataGridCell ControlTemplate that slowed rendering way down.
Be aware that relative loading speeds for large dataset are very different for using TextBlock (that is not selectable text) or TextBox in ReadOnly mode:
Loading time 59 seconds:
<Style TargetType="{x:Type DataGridCell}" x:Key="DataGridCellTextStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<TextBox IsReadOnly="True" Text="{Binding Mode=OneWay}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Loading time 21 seconds:
<Style TargetType="{x:Type DataGridCell}" x:Key="DataGridCellTextStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<ContentPresenter Content="{Binding}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Loading time 16 seconds:
<Style TargetType="{x:Type DataGridCell}" x:Key="DataGridCellTextStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<TextBlock Text="{Binding}"></TextBlock>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>