Hi,
I have a one form and I try to display data in DataGrid control with 100,000 rows & 10 columns and filling grid from DataTable. It works fine. I try to display data in TextBlock and adding TextBlock in StackPanel. But it takes to much time to display while DataGrid is faster. What kind of improvement I required in my code.
Here code is displayed.
///// Designing<Window x:Class="ToolBarApp.frmSearch" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" WindowStartupLocation="CenterScreen" Title="frmSearch" Height="500" Width="500" ><Grid><ScrollViewer><StackPanel Name="ctl_Display"></StackPanel></ScrollViewer></Grid></Window> //// Constructor public frmSearch(bool AddToGrid, DataTable _dt) { InitializeComponent(); if (AddToGrid) { DataGrid _dg = new DataGrid(); _dg.Height = 450; _dg.Width = 450; _dg.AutoGenerateColumns = true; _dg.ItemsSource = _dt.DefaultView; ctl_Display.Children.Add(_dg); } else { TextBlock _TextBlock; foreach (DataRow _DR in _dt.Rows) { _TextBlock = new TextBlock(); _TextBlock.Margin = new Thickness(0); _TextBlock.FontSize = 14; _TextBlock.Foreground = Brushes.White; _TextBlock.Text = _DR["Item_Name"].ToString(); ctl_Display.Children.Add(_TextBlock); } } }