如何为大数据快速设置wpf datagrid渲染? [英] how to set wpf datagrid rendering fast for large data?
本文介绍了如何为大数据快速设置wpf datagrid渲染?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何为大数据快速设置wpf datagrid渲染?帮帮我。
搜索按钮点击事件
how to set wpf datagrid rendering fast for large data? help with me.
Search button click event
private void Search_Click(object sender, RoutedEventArgs e)
{
try
{
dgMMSize.ItemsSource = _mmsize.GetMMSize(txtId.Text);
}
catch (Exception ex)
{
if (stack.ToLower() == "true")
logService.Error(ex.ToString());
else
logService.Error(ex.Message.ToString());
MessageBox.Show(ex.Message);
}
}
在显示任何数据之前,点击需要16秒。
Search click takes 16 sec before any data is showing.
推荐答案
在_mmsize.GetMMSize(txtId.Text)中获取数据需要多长时间?
更改您代码:
How long time does it take to get data in "_mmsize.GetMMSize(txtId.Text)" ?
Change you code to:
System.Diagnostics.Stopwatch t1 = System.Diagnostics.Stopwatch.StartNew();
var data = _mmsize.GetMMSize(txtId.Text);
t1.Stop();
MessageBox.Show(t1.Elapsed);
t1.Restart();
dgMMSize.ItemsSource = data;
t1.Stop();
MessageBox.Show(t1.Elapsed);
也许是在SQL中搜索?
在WPF中正常,你只需设置一次ItemsSource并使用Filter函数来告诉DataGrid必须显示哪些数据。
我的猜测是_mmsize.GetMMSize正在进行SQL搜索并返回一个数组或数据列表?
Perhaps it is a search in SQL ?
Normal in WPF, you only set ItemsSource one time and uses Filter functions to tell what data DataGrid has to show.
My guess is that "_mmsize.GetMMSize" is doing a SQL search and returns an array or list of data ?
这篇关于如何为大数据快速设置wpf datagrid渲染?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文