Is there a way to speed up when copying WPF DataGrid with many rows?

jun1.lee 21 Reputation points
2022-11-14T23:38:20.407+00:00

I have created a program that shows SQL DB and shows it on the DataGrid.
Originally, someone was made of Winform, but it was newly made with WPF for improvement.
If I look up the SQL DB, about 18,000 rows are inquired.
While working, I sometimes copy all rows to Ctrl+C, but the DataGrid stops completely after being too slow and choosing.
There are so many rows that seem to be overloaded.
However, if I look up the same SQL DB with the existing program Winform and copy it, I can copy it in 1 second and paste it with Excel very quickly.
I want to implement this behavior as WPF DataGrid, but I don't know a good way. Who can help me? In addition, attach XAML.
And I don't have winform code someone made.

<DataGrid x:Name="dg_tr" ItemsSource="{Binding}" AutoGenerateColumns="False"   
                                    FontSize="12" Margin="10 10 5 0"                           
                                    Width="850" Height="500"  
                                    RowHeaderWidth ="NaN"  
                                    CanUserResizeRows="False"    
                                    ClipboardCopyMode="{Binding ElementName=chk_header_copy, Path=IsChecked, Converter={StaticResource dg_CopyHeaderCopyModeConverter}}"  
                                    CanUserAddRows="False"        
                                    IsReadOnly="True"  
                                    LoadingRow="dg_tr_recipe_LoadingRow"  
                                    GridLinesVisibility="All" HorizontalGridLinesBrush="LightGray"  
                                    VerticalGridLinesBrush="LightGray"  
                                    EnableRowVirtualization="True"  
                                    EnableColumnVirtualization="True"   
                                    ScrollViewer.CanContentScroll="True"  
                                    VirtualizingStackPanel.IsVirtualizing="True"   
                                    VirtualizingStackPanel.VirtualizationMode="Recycling"  
                                    PreviewMouseDoubleClick="dg_tr_recipe_PreviewMouseDoubleClick"                                                
                                    SelectionUnit="Cell">  
                            <DataGrid.Resources>  
                                <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="{x:Static SystemColors.HighlightColor}"/>  
                                <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}" Color="{x:Static SystemColors.HighlightTextColor}"/>  
                            </DataGrid.Resources>  
                            <DataGrid.Columns>  
                                <DataGridTextColumn Binding = "{Binding Path = col1}" Header="col1"/>  
                                <DataGridTextColumn Binding = "{Binding Path = col2}" Header="col2"/>  
                                <DataGridTextColumn Binding = "{Binding Path = col3}" Header="col3"/>  
                                <DataGridTextColumn Binding = "{Binding Path = col4}" Header="col4"/>  
                                <DataGridTextColumn Binding = "{Binding Path = col5}" Header="col5"/>  
                                <DataGridTextColumn Binding = "{Binding Path = col6}" Header="col6"/>  
                                <DataGridTextColumn Binding = "{Binding Path = col7}" Header="col7"/>  
                                <DataGridTextColumn Binding = "{Binding Path = col8}" Header="col8"/>  
                                <DataGridTextColumn Binding = "{Binding Path = col9}" Header="col9"/>  
                                <DataGridTextColumn Binding = "{Binding Path = col10}" Header="col10"/>  
                                <DataGridTextColumn Binding = "{Binding Path = col11}" Header="col11"/>  
                                <DataGridTextColumn Binding = "{Binding Path = col12}" Header="col12"/>  
                                <DataGridTextColumn Binding = "{Binding Path = col13}" Header="col13"/>  
                                <DataGridTextColumn Binding = "{Binding Path = col14}" Header="col14"/>  
                                <DataGridTextColumn Binding = "{Binding Path = col15}" Header="col15"/>  
                                <DataGridTextColumn Binding = "{Binding Path = col16}" Header="col16"/>  
                                <DataGridTextColumn Binding = "{Binding Path = col17}" Header="col17"/>  
                                <DataGridTextColumn Binding = "{Binding Path = col18}" Header="col18"/>  
                                <DataGridTextColumn Binding = "{Binding Path = col19}" Header="col19"/>  
                                  
                            </DataGrid.Columns>  
                        </DataGrid>  
Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,869 questions
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,709 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,619 questions
{count} votes