首页 新闻 搜索 专区 学院

WPF ListView 显示大数据

0
悬赏园豆:5 [已解决问题] 解决于 2022-10-11 15:04

不得不说客户需求很BT

在 WPF ListView 中,显示列数达到500,行数超过5万行。

虽然能显示,但垂直滚动条拖动时会很卡。

有什么优化方案吗?

血狼一族的主页 血狼一族 | 初学一级 | 园豆:60
提问于:2022-09-08 14:59
< >
分享
最佳答案
0

关键字搜索wpf UI Virtualization

收获园豆:5
MrNice | 老鸟四级 |园豆:3248 | 2022-09-08 15:04
其他回答(6)
0

1、VirtualizingPanel UI虚拟化

2、数据延迟加载就是滚动到底部才加载新的数据类似微博那样 ,或者就是分页一页显示固定行数分多页

左眼水星 | 园豆:120 (初学一级) | 2022-09-08 15:30

这个试过了,好象没什么变化

支持(0) 反对(0) 血狼一族 | 园豆:60 (初学一级) | 2022-09-08 15:53
0

这样的需求应该驳回。

客户这样做的目的是什么?能不能通过其他手段达到相同或更好的效果?

会长 | 园豆:11840 (专家六级) | 2022-09-08 15:31

其实我早就特么想驳回了

这是工控上位机里显示对电池管理系统(BMS)的采样数据,一个BMS接了可能有400个单体电芯,每个电芯有单体电压、单体温度,这特么加起来就800个信号了。

其实只需要显示最大最小值就可以了,关键是设备有没有处于危险中。但客户说他们会看,不过我信你个鬼。

支持(0) 反对(0) 血狼一族 | 园豆:60 (初学一级) | 2022-09-08 15:52

@血狼一族: 800个能看过来吗....。我建议是这样:用户其实关心的是是否异常,可以让用户自己设置一些阈值,程序自动监控,如果某些数据超过阈值,就报警,用户可以快速定位到问题数据。。如果非要全看,加上分页和查询过滤。

支持(0) 反对(0) 会长 | 园豆:11840 (专家六级) | 2022-09-08 16:02

@会长: 

谁都知道看不过来啊!但是客户就是说我要看!

现在正在找别的门路跟客户沟通去掉这么BT的要求。

我的担心是,万一WPF(或者WinForm,主要客户才不关注你是WPF还是WinForm,甚至可能是 Delphi )确实能够支持这种BT功能,不然客户拿别的产品往你面前一摆:瞧,人家咋搞得定,你咋就不行!

支持(0) 反对(0) 血狼一族 | 园豆:60 (初学一级) | 2022-09-12 16:20

@血狼一族: 我还有一个疑问,为什么用listview,而不用datagrid?听你的描述datagrid更合适。另外,你那里有可以运行的demo吗,发上来,我想在你demo的基础上试试看

支持(0) 反对(0) 会长 | 园豆:11840 (专家六级) | 2022-09-13 11:14

@血狼一族: 我用datagrid试了绑定50000行600列,确实有点卡,我想想用什么办法能绑定少了数据,通过多次绑定来实现

支持(0) 反对(0) 会长 | 园豆:11840 (专家六级) | 2022-09-13 11:35

@血狼一族: 你有试开启虚拟化吗,我试了下,效果挺好的:

    <Grid>
        <DataGrid ItemsSource="{Binding DataList}"
                  VirtualizingPanel.ScrollUnit="Pixel"
                  EnableColumnVirtualization="True"
                  EnableRowVirtualization="True">            
        </DataGrid>
    </Grid>
namespace WPFListViewDemo
{
    internal class ViewModel
    {
        public ViewModel()
        {
            DataList = InitData();
        }

        private List<Data> InitData()
        {
            List<Data> datalist = new List<Data>();

            Type info = typeof(Data);
            var properties = info.GetProperties();

            for (int i = 0; i < 50000; i++)
            {
                Data data = new Data();
             
                foreach (var property in properties)
                {
                    property.SetValue(data, property.Name + i.ToString());
                }

                datalist.Add(data);
            }

            return datalist;
        }

        public List<Data> DataList { get; set; }
    }

    public class Data
    {
        public string Col1 { get; set; }
        public string Col2 { get; set; }
        public string Col3 { get; set; }
        public string Col4 { get; set; }
        public string Col5 { get; set; }
        public string Col6 { get; set; }
        public string Col7 { get; set; }
        public string Col8 { get; set; }
        public string Col9 { get; set; }
        public string Col10 { get; set; }
        public string Col11 { get; set; }
        public string Col12 { get; set; }
        public string Col13 { get; set; }
        public string Col14 { get; set; }
        public string Col15 { get; set; }
        public string Col16 { get; set; }
        public string Col17 { get; set; }
        public string Col18 { get; set; }
        public string Col19 { get; set; }
        public string Col20 { get; set; }
        public string Col21 { get; set; }
        public string Col22 { get; set; }
        public string Col23 { get; set; }
        public string Col24 { get; set; }
        public string Col25 { get; set; }
        public string Col26 { get; set; }
        public string Col27 { get; set; }
        public string Col28 { get; set; }
        public string Col29 { get; set; }
        public string Col30{ get; set; }
        public string Col31 { get; set; }
        public string Col32 { get; set; }
        public string Col33 { get; set; }
        public string Col34 { get; set; }
        public string Col35 { get; set; }
        public string Col36 { get; set; }
        public string Col37 { get; set; }
        public string Col38 { get; set; }
        public string Col39 { get; set; }
        public string Col40 { get; set; }
        public string Col41 { get; set; }
        public string Col42 { get; set; }
        public string Col43 { get; set; }
        public string Col44 { get; set; }
        public string Col45 { get; set; }
        public string Col46 { get; set; }
        public string Col47 { get; set; }
        public string Col48 { get; set; }
        public string Col49 { get; set; }
        public string Col50 { get; set; }
        public string ACol1 { get; set; }
        public string ACol2 { get; set; }
        public string ACol3 { get; set; }
        public string ACol4 { get; set; }
        public string ACol5 { get; set; }
        public string ACol6 { get; set; }
        public string ACol7 { get; set; }
        public string ACol8 { get; set; }
        public string ACol9 { get; set; }
        public string ACol10 { get; set; }
        public string ACol11 { get; set; }
        public string ACol12 { get; set; }
        public string ACol13 { get; set; }
        public string ACol14 { get; set; }
        public string ACol15 { get; set; }
        public string ACol16 { get; set; }
        public string ACol17 { get; set; }
        public string ACol18 { get; set; }
        public string ACol19 { get; set; }
        public string ACol20 { get; set; }
        public string ACol21 { get; set; }
        public string ACol22 { get; set; }
        public string ACol23 { get; set; }
        public string ACol24 { get; set; }
        public string ACol25 { get; set; }
        public string ACol26 { get; set; }
        public string ACol27 { get; set; }
        public string ACol28 { get; set; }
        public string ACol29 { get; set; }
        public string ACol30 { get; set; }
        public string ACol31 { get; set; }
        public string ACol32 { get; set; }
        public string ACol33 { get; set; }
        public string ACol34 { get; set; }
        public string ACol35 { get; set; }
        public string ACol36 { get; set; }
        public string ACol37 { get; set; }
        public string ACol38 { get; set; }
        public string ACol39 { get; set; }
        public string ACol40 { get; set; }
        public string ACol41 { get; set; }
        public string ACol42 { get; set; }
        public string ACol43 { get; set; }
        public string ACol44 { get; set; }
        public string ACol45 { get; set; }
        public string ACol46 { get; set; }
        public string ACol47 { get; set; }
        public string ACol48 { get; set; }
        public string ACol49 { get; set; }
        public string ACol50 { get; set; }
        public string BCol1 { get; set; }
        public string BCol2 { get; set; }
        public string BCol3 { get; set; }
        public string BCol4 { get; set; }
        public string BCol5 { get; set; }
        public string BCol6 { get; set; }
        public string BCol7 { get; set; }
        public string BCol8 { get; set; }
        public string BCol9 { get; set; }
        public string BCol10 { get; set; }
        public string BCol11 { get; set; }
        public string BCol12 { get; set; }
        public string BCol13 { get; set; }
        public string BCol14 { get; set; }
        public string BCol15 { get; set; }
        public string BCol16 { get; set; }
        public string BCol17 { get; set; }
        public string BCol18 { get; set; }
        public string BCol19 { get; set; }
        public string BCol20 { get; set; }
        public string BCol21 { get; set; }
        public string BCol22 { get; set; }
        public string BCol23 { get; set; }
        public string BCol24 { get; set; }
        public string BCol25 { get; set; }
        public string BCol26 { get; set; }
        public string BCol27 { get; set; }
        public string BCol28 { get; set; }
        public string BCol29 { get; set; }
        public string BCol30 { get; set; }
        public string BCol31 { get; set; }
        public string BCol32 { get; set; }
        public string BCol33 { get; set; }
        public string BCol34 { get; set; }
        public string BCol35 { get; set; }
        public string BCol36 { get; set; }
        public string BCol37 { get; set; }
        public string BCol38 { get; set; }
        public string BCol39 { get; set; }
        public string BCol40 { get; set; }
        public string BCol41 { get; set; }
        public string BCol42 { get; set; }
        public string BCol43 { get; set; }
        public string BCol44 { get; set; }
        public string BCol45 { get; set; }
        public string BCol46 { get; set; }
        public string BCol47 { get; set; }
        public string BCol48 { get; set; }
        public string BCol49 { get; set; }
        public string BCol50 { get; set; }
        public string BACol1 { get; set; }
        public string BACol2 { get; set; }
        public string BACol3 { get; set; }
        public string BACol4 { get; set; }
        public string BACol5 { get; set; }
        public string BACol6 { get; set; }
        public string BACol7 { get; set; }
        public string BACol8 { get; set; }
        public string BACol9 { get; set; }
        public string BACol10 { get; set; }
        public string BACol11 { get; set; }
        public string BACol12 { get; set; }
        public string BACol13 { get; set; }
        public string BACol14 { get; set; }
        public string BACol15 { get; set; }
        public string BACol16 { get; set; }
        public string BACol17 { get; set; }
        public string BACol18 { get; set; }
        public string BACol19 { get; set; }
        public string BACol20 { get; set; }
        public string BACol21 { get; set; }
        public string BACol22 { get; set; }
        public string BACol23 { get; set; }
        public string BACol24 { get; set; }
        public string BACol25 { get; set; }
        public string BACol26 { get; set; }
        public string BACol27 { get; set; }
        public string BACol28 { get; set; }
        public string BACol29 { get; set; }
        public string BACol30 { get; set; }
        public string BACol31 { get; set; }
        public string BACol32 { get; set; }
        public string BACol33 { get; set; }
        public string BACol34 { get; set; }
        public string BACol35 { get; set; }
        public string BACol36 { get; set; }
        public string BACol37 { get; set; }
        public string BACol38 { get; set; }
        public string BACol39 { get; set; }
        public string BACol40 { get; set; }
        public string BACol41 { get; set; }
        public string BACol42 { get; set; }
        public string BACol43 { get; set; }
        public string BACol44 { get; set; }
        public string BACol45 { get; set; }
        public string BACol46 { get; set; }
        public string BACol47 { get; set; }
        public string BACol48 { get; set; }
        public string BACol49 { get; set; }
        public string BACol50 { get; set; }
        public string CBCol1 { get; set; }
        public string CBCol2 { get; set; }
        public string CBCol3 { get; set; }
        public string CBCol4 { get; set; }
        public string CBCol5 { get; set; }
        public string CBCol6 { get; set; }
        public string CBCol7 { get; set; }
        public string CBCol8 { get; set; }
        public string CBCol9 { get; set; }
        public string CBCol10 { get; set; }
        public string CBCol11 { get; set; }
        public string CBCol12 { get; set; }
        public string CBCol13 { get; set; }
        public string CBCol14 { get; set; }
        public string CBCol15 { get; set; }
        public string CBCol16 { get; set; }
        public string CBCol17 { get; set; }
        public string CBCol18 { get; set; }
        public string CBCol19 { get; set; }
        public string CBCol20 { get; set; }
        public string CBCol21 { get; set; }
        public string CBCol22 { get; set; }
        public string CBCol23 { get; set; }
        public string CBCol24 { get; set; }
        public string CBCol25 { get; set; }
        public string CBCol26 { get; set; }
        public string CBCol27 { get; set; }
        public string CBCol28 { get; set; }
        public string CBCol29 { get; set; }
        public string CBCol30 { get; set; }
        public string CBCol31 { get; set; }
        public string CBCol32 { get; set; }
        public string CBCol33 { get; set; }
        public string CBCol34 { get; set; }
        public string CBCol35 { get; set; }
        public string CBCol36 { get; set; }
        public string CBCol37 { get; set; }
        public string CBCol38 { get; set; }
        public string CBCol39 { get; set; }
        public string CBCol40 { get; set; }
        public string CBCol41 { get; set; }
        public string CBCol42 { get; set; }
        public string CBCol43 { get; set; }
        public string CBCol44 { get; set; }
        public string CBCol45 { get; set; }
        public string CBCol46 { get; set; }
        public string CBCol47 { get; set; }
        public string CBCol48 { get; set; }
        public string CBCol49 { get; set; }
        public string CBCol50 { get; set; }
        public string CBACol1 { get; set; }
        public string CBACol2 { get; set; }
        public string CBACol3 { get; set; }
        public string CBACol4 { get; set; }
        public string CBACol5 { get; set; }
        public string CBACol6 { get; set; }
        public string CBACol7 { get; set; }
        public string CBACol8 { get; set; }
        public string CBACol9 { get; set; }
        public string CBACol10 { get; set; }
        public string CBACol11 { get; set; }
        public string CBACol12 { get; set; }
        public string CBACol13 { get; set; }
        public string CBACol14 { get; set; }
        public string CBACol15 { get; set; }
        public string CBACol16 { get; set; }
        public string CBACol17 { get; set; }
        public string CBACol18 { get; set; }
        public string CBACol19 { get; set; }
        public string CBACol20 { get; set; }
        public string CBACol21 { get; set; }
        public string CBACol22 { get; set; }
        public string CBACol23 { get; set; }
        public string CBACol24 { get; set; }
        public string CBACol25 { get; set; }
        public string CBACol26 { get; set; }
        public string CBACol27 { get; set; }
        public string CBACol28 { get; set; }
        public string CBACol29 { get; set; }
        public string CBACol30 { get; set; }
        public string CBACol31 { get; set; }
        public string CBACol32 { get; set; }
        public string CBACol33 { get; set; }
        public string CBACol34 { get; set; }
        public string CBACol35 { get; set; }
        public string CBACol36 { get; set; }
        public string CBACol37 { get; set; }
        public string CBACol38 { get; set; }
        public string CBACol39 { get; set; }
        public string CBACol40 { get; set; }
        public string CBACol41 { get; set; }
        public string CBACol42 { get; set; }
        public string CBACol43 { get; set; }
        public string CBACol44 { get; set; }
        public string CBACol45 { get; set; }
        public string CBACol46 { get; set; }
        public string CBACol47 { get; set; }
        public string CBACol48 { get; set; }
        public string CBACol49 { get; set; }
        public string CBACol50 { get; set; }
        public string ABCCol1 { get; set; }
        public string ABCCol2 { get; set; }
        public string ABCCol3 { get; set; }
        public string ABCCol4 { get; set; }
        public string ABCCol5 { get; set; }
        public string ABCCol6 { get; set; }
        public string ABCCol7 { get; set; }
        public string ABCCol8 { get; set; }
        public string ABCCol9 { get; set; }
        public string ABCCol10 { get; set; }
        public string ABCCol11 { get; set; }
        public string ABCCol12 { get; set; }
        public string ABCCol13 { get; set; }
        public string ABCCol14 { get; set; }
        public string ABCCol15 { get; set; }
        public string ABCCol16 { get; set; }
        public string ABCCol17 { get; set; }
        public string ABCCol18 { get; set; }
        public string ABCCol19 { get; set; }
        public string ABCCol20 { get; set; }
        public string ABCCol21 { get; set; }
        public string ABCCol22 { get; set; }
        public string ABCCol23 { get; set; }
        public string ABCCol24 { get; set; }
        public string ABCCol25 { get; set; }
        public string ABCCol26 { get; set; }
        public string ABCCol27 { get; set; }
        public string ABCCol28 { get; set; }
        public string ABCCol29 { get; set; }
        public string ABCCol30 { get; set; }
        public string ABCCol31 { get; set; }
        public string ABCCol32 { get; set; }
        public string ABCCol33 { get; set; }
        public string ABCCol34 { get; set; }
        public string ABCCol35 { get; set; }
        public string ABCCol36 { get; set; }
        public string ABCCol37 { get; set; }
        public string ABCCol38 { get; set; }
        public string ABCCol39 { get; set; }
        public string ABCCol40 { get; set; }
        public string ABCCol41 { get; set; }
        public string ABCCol42 { get; set; }
        public string ABCCol43 { get; set; }
        public string ABCCol44 { get; set; }
        public string ABCCol45 { get; set; }
        public string ABCCol46 { get; set; }
        public string ABCCol47 { get; set; }
        public string ABCCol48 { get; set; }
        public string ABCCol49 { get; set; }
        public string ABCCol50 { get; set; }
        public string ABCACol1 { get; set; }
        public string ABCACol2 { get; set; }
        public string ABCACol3 { get; set; }
        public string ABCACol4 { get; set; }
        public string ABCACol5 { get; set; }
        public string ABCACol6 { get; set; }
        public string ABCACol7 { get; set; }
        public string ABCACol8 { get; set; }
        public string ABCACol9 { get; set; }
        public string ABCACol10 { get; set; }
        public string ABCACol11 { get; set; }
        public string ABCACol12 { get; set; }
        public string ABCACol13 { get; set; }
        public string ABCACol14 { get; set; }
        public string ABCACol15 { get; set; }
        public string ABCACol16 { get; set; }
        public string ABCACol17 { get; set; }
        public string ABCACol18 { get; set; }
        public string ABCACol19 { get; set; }
        public string ABCACol20 { get; set; }
        public string ABCACol21 { get; set; }
        public string ABCACol22 { get; set; }
        public string ABCACol23 { get; set; }
        public string ABCACol24 { get; set; }
        public string ABCACol25 { get; set; }
        public string ABCACol26 { get; set; }
        public string ABCACol27 { get; set; }
        public string ABCACol28 { get; set; }
        public string ABCACol29 { get; set; }
        public string ABCACol30 { get; set; }
        public string ABCACol31 { get; set; }
        public string ABCACol32 { get; set; }
        public string ABCACol33 { get; set; }
        public string ABCACol34 { get; set; }
        public string ABCACol35 { get; set; }
        public string ABCACol36 { get; set; }
        public string ABCACol37 { get; set; }
        public string ABCACol38 { get; set; }
        public string ABCACol39 { get; set; }
        public string ABCACol40 { get; set; }
        public string ABCACol41 { get; set; }
        public string ABCACol42 { get; set; }
        public string ABCACol43 { get; set; }
        public string ABCACol44 { get; set; }
        public string ABCACol45 { get; set; }
        public string ABCACol46 { get; set; }
        public string ABCACol47 { get; set; }
        public string ABCACol48 { get; set; }
        public string ABCACol49 { get; set; }
        public string ABCACol50 { get; set; }
        public string ABCBCol1 { get; set; }
        public string ABCBCol2 { get; set; }
        public string ABCBCol3 { get; set; }
        public string ABCBCol4 { get; set; }
        public string ABCBCol5 { get; set; }
        public string ABCBCol6 { get; set; }
        public string ABCBCol7 { get; set; }
        public string ABCBCol8 { get; set; }
        public string ABCBCol9 { get; set; }
        public string ABCBCol10 { get; set; }
        public string ABCBCol11 { get; set; }
        public string ABCBCol12 { get; set; }
        public string ABCBCol13 { get; set; }
        public string ABCBCol14 { get; set; }
        public string ABCBCol15 { get; set; }
        public string ABCBCol16 { get; set; }
        public string ABCBCol17 { get; set; }
        public string ABCBCol18 { get; set; }
        public string ABCBCol19 { get; set; }
        public string ABCBCol20 { get; set; }
        public string ABCBCol21 { get; set; }
        public string ABCBCol22 { get; set; }
        public string ABCBCol23 { get; set; }
        public string ABCBCol24 { get; set; }
        public string ABCBCol25 { get; set; }
        public string ABCBCol26 { get; set; }
        public string ABCBCol27 { get; set; }
        public string ABCBCol28 { get; set; }
        public string ABCBCol29 { get; set; }
        public string ABCBCol30 { get; set; }
        public string ABCBCol31 { get; set; }
        public string ABCBCol32 { get; set; }
        public string ABCBCol33 { get; set; }
        public string ABCBCol34 { get; set; }
        public string ABCBCol35 { get; set; }
        public string ABCBCol36 { get; set; }
        public string ABCBCol37 { get; set; }
        public string ABCBCol38 { get; set; }
        public string ABCBCol39 { get; set; }
        public string ABCBCol40 { get; set; }
        public string ABCBCol41 { get; set; }
        public string ABCBCol42 { get; set; }
        public string ABCBCol43 { get; set; }
        public string ABCBCol44 { get; set; }
        public string ABCBCol45 { get; set; }
        public string ABCBCol46 { get; set; }
        public string ABCBCol47 { get; set; }
        public string ABCBCol48 { get; set; }
        public string ABCBCol49 { get; set; }
        public string ABCBCol50 { get; set; }
        public string ABCBACol1 { get; set; }
        public string ABCBACol2 { get; set; }
        public string ABCBACol3 { get; set; }
        public string ABCBACol4 { get; set; }
        public string ABCBACol5 { get; set; }
        public string ABCBACol6 { get; set; }
        public string ABCBACol7 { get; set; }
        public string ABCBACol8 { get; set; }
        public string ABCBACol9 { get; set; }
        public string ABCBACol10 { get; set; }
        public string ABCBACol11 { get; set; }
        public string ABCBACol12 { get; set; }
        public string ABCBACol13 { get; set; }
        public string ABCBACol14 { get; set; }
        public string ABCBACol15 { get; set; }
        public string ABCBACol16 { get; set; }
        public string ABCBACol17 { get; set; }
        public string ABCBACol18 { get; set; }
        public string ABCBACol19 { get; set; }
        public string ABCBACol20 { get; set; }
        public string ABCBACol21 { get; set; }
        public string ABCBACol22 { get; set; }
        public string ABCBACol23 { get; set; }
        public string ABCBACol24 { get; set; }
        public string ABCBACol25 { get; set; }
        public string ABCBACol26 { get; set; }
        public string ABCBACol27 { get; set; }
        public string ABCBACol28 { get; set; }
        public string ABCBACol29 { get; set; }
        public string ABCBACol30 { get; set; }
        public string ABCBACol31 { get; set; }
        public string ABCBACol32 { get; set; }
        public string ABCBACol33 { get; set; }
        public string ABCBACol34 { get; set; }
        public string ABCBACol35 { get; set; }
        public string ABCBACol36 { get; set; }
        public string ABCBACol37 { get; set; }
        public string ABCBACol38 { get; set; }
        public string ABCBACol39 { get; set; }
        public string ABCBACol40 { get; set; }
        public string ABCBACol41 { get; set; }
        public string ABCBACol42 { get; set; }
        public string ABCBACol43 { get; set; }
        public string ABCBACol44 { get; set; }
        public string ABCBACol45 { get; set; }
        public string ABCBACol46 { get; set; }
        public string ABCBACol47 { get; set; }
        public string ABCBACol48 { get; set; }
        public string ABCBACol49 { get; set; }
        public string ABCBACol50 { get; set; }
        public string ABCCBCol1 { get; set; }
        public string ABCCBCol2 { get; set; }
        public string ABCCBCol3 { get; set; }
        public string ABCCBCol4 { get; set; }
        public string ABCCBCol5 { get; set; }
        public string ABCCBCol6 { get; set; }
        public string ABCCBCol7 { get; set; }
        public string ABCCBCol8 { get; set; }
        public string ABCCBCol9 { get; set; }
        public string ABCCBCol10 { get; set; }
        public string ABCCBCol11 { get; set; }
        public string ABCCBCol12 { get; set; }
        public string ABCCBCol13 { get; set; }
        public string ABCCBCol14 { get; set; }
        public string ABCCBCol15 { get; set; }
        public string ABCCBCol16 { get; set; }
        public string ABCCBCol17 { get; set; }
        public string ABCCBCol18 { get; set; }
        public string ABCCBCol19 { get; set; }
        public string ABCCBCol20 { get; set; }
        public string ABCCBCol21 { get; set; }
        public string ABCCBCol22 { get; set; }
        public string ABCCBCol23 { get; set; }
        public string ABCCBCol24 { get; set; }
        public string ABCCBCol25 { get; set; }
        public string ABCCBCol26 { get; set; }
        public string ABCCBCol27 { get; set; }
        public string ABCCBCol28 { get; set; }
        public string ABCCBCol29 { get; set; }
        public string ABCCBCol30 { get; set; }
        public string ABCCBCol31 { get; set; }
        public string ABCCBCol32 { get; set; }
        public string ABCCBCol33 { get; set; }
        public string ABCCBCol34 { get; set; }
        public string ABCCBCol35 { get; set; }
        public string ABCCBCol36 { get; set; }
        public string ABCCBCol37 { get; set; }
        public string ABCCBCol38 { get; set; }
        public string ABCCBCol39 { get; set; }
        public string ABCCBCol40 { get; set; }
        public string ABCCBCol41 { get; set; }
        public string ABCCBCol42 { get; set; }
        public string ABCCBCol43 { get; set; }
        public string ABCCBCol44 { get; set; }
        public string ABCCBCol45 { get; set; }
        public string ABCCBCol46 { get; set; }
        public string ABCCBCol47 { get; set; }
        public string ABCCBCol48 { get; set; }
        public string ABCCBCol49 { get; set; }
        public string ABCCBCol50 { get; set; }
        public string ABCCBACol1 { get; set; }
        public string ABCCBACol2 { get; set; }
        public string ABCCBACol3 { get; set; }
        public string ABCCBACol4 { get; set; }
        public string ABCCBACol5 { get; set; }
        public string ABCCBACol6 { get; set; }
        public string ABCCBACol7 { get; set; }
        public string ABCCBACol8 { get; set; }
        public string ABCCBACol9 { get; set; }
        public string ABCCBACol10 { get; set; }
        public string ABCCBACol11 { get; set; }
        public string ABCCBACol12 { get; set; }
        public string ABCCBACol13 { get; set; }
        public string ABCCBACol14 { get; set; }
        public string ABCCBACol15 { get; set; }
        public string ABCCBACol16 { get; set; }
        public string ABCCBACol17 { get; set; }
        public string ABCCBACol18 { get; set; }
        public string ABCCBACol19 { get; set; }
        public string ABCCBACol20 { get; set; }
        public string ABCCBACol21 { get; set; }
        public string ABCCBACol22 { get; set; }
        public string ABCCBACol23 { get; set; }
        public string ABCCBACol24 { get; set; }
        public string ABCCBACol25 { get; set; }
        public string ABCCBACol26 { get; set; }
        public string ABCCBACol27 { get; set; }
        public string ABCCBACol28 { get; set; }
        public string ABCCBACol29 { get; set; }
        public string ABCCBACol30 { get; set; }
        public string ABCCBACol31 { get; set; }
        public string ABCCBACol32 { get; set; }
        public string ABCCBACol33 { get; set; }
        public string ABCCBACol34 { get; set; }
        public string ABCCBACol35 { get; set; }
        public string ABCCBACol36 { get; set; }
        public string ABCCBACol37 { get; set; }
        public string ABCCBACol38 { get; set; }
        public string ABCCBACol39 { get; set; }
        public string ABCCBACol40 { get; set; }
        public string ABCCBACol41 { get; set; }
        public string ABCCBACol42 { get; set; }
        public string ABCCBACol43 { get; set; }
        public string ABCCBACol44 { get; set; }
        public string ABCCBACol45 { get; set; }
        public string ABCCBACol46 { get; set; }
        public string ABCCBACol47 { get; set; }
        public string ABCCBACol48 { get; set; }
        public string ABCCBACol49 { get; set; }
        public string ABCCBACol50 { get; set; }
    }
}
支持(0) 反对(0) 会长 | 园豆:11840 (专家六级) | 2022-09-13 11:53

@会长: DataGrid 比 ListView 更卡

以下是测试程序

<Window x:Class="TestListView.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:TestListView"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <TabControl>
            <TabItem Header="使用 ListView">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="30" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right">
                        <Button Name="btnCreateData1" Width="60" Height="23" Content="创建数据" Margin="2" Click="btnCreateData1_Click" />
                    </StackPanel>
                    <ListView Grid.Row="1" Name="listViewBind" 
                              VirtualizingPanel.IsVirtualizing="True"
                              ScrollViewer.CanContentScroll ="True"
                              VirtualizingPanel.ScrollUnit="Pixel"
                              VirtualizingStackPanel.VirtualizationMode="Recycling">
                        <ListView.View>
                            <GridView x:Name="gridViewBind">
                                <GridView.Columns>
                                    
                                </GridView.Columns>
                            </GridView>
                        </ListView.View>
                    </ListView>
                </Grid>
            </TabItem>
            <TabItem Header="使用 DataGrid">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="30" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right">
                        <Button Name="btnCreateData2" Width="60" Height="23" Content="创建数据" Margin="2" Click="btnCreateData2_Click" />
                    </StackPanel>
                    <DataGrid Grid.Row="1" Name="dataGrid1" AutoGenerateColumns="False">
                        
                    </DataGrid>
                </Grid>
            </TabItem>
        </TabControl>
    </Grid>
</Window>

 

  1 using System;
  2 using System.Collections.Generic;
  3 using System.Linq;
  4 using System.Text;
  5 using System.Threading.Tasks;
  6 using System.Windows;
  7 using System.Windows.Controls;
  8 using System.Windows.Data;
  9 using System.Windows.Documents;
 10 using System.Windows.Input;
 11 using System.Windows.Media;
 12 using System.Windows.Media.Imaging;
 13 using System.Windows.Navigation;
 14 using System.Windows.Shapes;
 15 
 16 namespace TestListView {
 17     
 18     public class MyData {
 19         public int Sn {
 20             get;
 21             set;
 22         }
 23         
 24         public Dictionary<string, string> Value {
 25             get;
 26             set;
 27         } = new Dictionary<string, string>();
 28     }
 29     
 30     /// <summary>
 31     /// Interaction logic for MainWindow.xaml
 32     /// </summary>
 33     public partial class MainWindow : Window {
 34         private const int Column_Count = 500;
 35         private const int Row_Count = 1000;
 36         private static readonly Random rdm = new Random();
 37         
 38         public MainWindow() {
 39             InitializeComponent();
 40         }
 41 
 42         private void ResetColumns(GridView gridView) {
 43             gridView.Columns.Clear();
 44 
 45             Binding bindingSn = new Binding("Sn");
 46             bindingSn.Mode = BindingMode.OneTime;
 47             bindingSn.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
 48             GridViewColumn colSn = new GridViewColumn();
 49             colSn.Width = 100;
 50             colSn.Header = "序号";
 51             colSn.DisplayMemberBinding = bindingSn;
 52             gridView.Columns.Add(colSn);
 53             
 54             for(int i=1; i<=Column_Count; i++) {
 55                 string strIdx = i.ToString().PadLeft(3, '0');
 56                 Binding binding = new Binding($"Value[Signal_{strIdx}]");
 57                 binding.Mode = BindingMode.OneTime;
 58                 binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
 59                 
 60                 GridViewColumn col = new GridViewColumn();
 61                 col.Width = 120;
 62                 col.Header = "信号 " + i.ToString().PadLeft(3, '0');
 63                 col.DisplayMemberBinding = binding;
 64                 
 65                 gridView.Columns.Add(col);
 66             }
 67         }
 68 
 69         private void ResetColumns(DataGrid dataGrid) {
 70             dataGrid.Columns.Clear();
 71 
 72             Binding bindingSn = new Binding("Sn");
 73             bindingSn.Mode = BindingMode.OneTime;
 74             bindingSn.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
 75             
 76             DataGridTextColumn colSn = new DataGridTextColumn();
 77             colSn.Header = "序号";
 78             colSn.Width = 60;
 79             colSn.Binding = bindingSn;
 80             dataGrid.Columns.Add(colSn);
 81             
 82             for(int i=1; i<=Column_Count; i++) {
 83                 string strIdx = i.ToString().PadLeft(3, '0');
 84                 Binding binding = new Binding($"Value[Signal_{strIdx}]");
 85                 binding.Mode = BindingMode.OneTime;
 86                 binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
 87 
 88                 DataGridTextColumn col = new DataGridTextColumn();
 89                 col.Width = 120;
 90                 col.Header = "信号 " + i.ToString().PadLeft(3, '0');
 91                 col.Binding = binding;
 92 
 93                 dataGrid.Columns.Add(col);
 94             }
 95         }
 96         
 97         private List<MyData> CreateDataList() {
 98             List<MyData> list = new List<MyData>();
 99             for (int i = 0; i < Row_Count; i++) {
100                 MyData data = new MyData();
101                 data.Sn = i + 1;
102                 for (int j = 1; j <= Column_Count; j++) {
103                     string strIdx = j.ToString().PadLeft(3, '0');
104                     data.Value[$"Signal_{strIdx}"] = (rdm.NextDouble() * 100).ToString("F4");
105                 }
106                 list.Add(data);
107             }
108             return list;
109         }
110 
111         private void ResetDataGridColumn(DataGrid dataGrid) {
112 
113         }
114         
115         private void btnCreateData1_Click(object sender, RoutedEventArgs e) {
116             this.ResetColumns(this.gridViewBind);
117             this.listViewBind.ItemsSource = this.CreateDataList();
118         }
119 
120         private void btnCreateData2_Click(object sender, RoutedEventArgs e) {
121             this.ResetColumns(this.dataGrid1);
122             this.dataGrid1.ItemsSource = this.CreateDataList();
123         }
124     }
125 }

 

支持(0) 反对(0) 血狼一族 | 园豆:60 (初学一级) | 2022-09-13 11:56

@血狼一族: 你留个邮箱,我把我写的demo发你,反正我这里一点不卡(我demo里卡是因为加载测试数据耗时,加载后在datagrid上面操作时挺流畅的)。

支持(0) 反对(0) 会长 | 园豆:11840 (专家六级) | 2022-09-13 12:02

@会长: 14011505@qq.com

支持(0) 反对(0) 血狼一族 | 园豆:60 (初学一级) | 2022-09-15 13:51

@血狼一族: 已发

支持(0) 反对(0) 会长 | 园豆:11840 (专家六级) | 2022-09-15 14:21

  再想问一句,如果显卡好一点,会不会有帮助?

支持(0) 反对(0) 血狼一族 | 园豆:60 (初学一级) | 2022-09-22 18:11

@血狼一族: 应该会有吧,不过可能不明显。我发的那个代码也不行吗?

支持(0) 反对(0) 会长 | 园豆:11840 (专家六级) | 2022-09-22 19:32

@会长: 参考你的代码,用 DataGrid 取代原来的 ListView,再加上虚拟化,已经好很多了。但在数据量大时还是有点卡。ListView 加虚拟化似乎没什么变化。

支持(0) 反对(0) 血狼一族 | 园豆:60 (初学一级) | 2022-09-23 11:54
0

试试分页?

echo_lovely | 园豆:903 (小虾三级) | 2022-09-09 08:34
0

前面也很多都和题主一样,认为这个需求很BT。其实用户的想法很没那么复杂,单纯的用Excle表格习惯了而已。
对用户来说,分页、拉到底才加载(下拉分页)什么的用起来麻烦。
而且工业软件和平台互联网应用不太一样,很容易出现需要大量展示数据的场景,不能完全说需求变态。
我们也遇到过这样的需求,只是我们是Web端,表格列和行极限大约在30/1W多的样子,而且我们的数据是还需要实时更新,更新延迟要控制在1分钟内。先前做分页,渐进加载被客户投诉好几回,开会讨论好多回,最后老板拍板,把那些都删除了,后来就是大帐户一登录就卡得一塌糊涂,客户反而不投诉了,开始反映系统卡但闹得也没这么凶了。然后,就是漫长的解决问题之路,讨论怎么拆分业务不显示这么多数据,表格虚拟化等,反正现在还行,双方都可以接受。

如里业务确实无法拆分,要实现这个,只能从虚拟化入手,毕竟用户可视区就那么大。但是基本上都需要定制,用控制内置的效果可能不太理想。我们先前的项目改造的重点就是去掉vue表格原生数据变动监听(自定义虚拟化渲染)。
难点往往在于识别那些行/列是当前显示在用户视区范围内的,然后用户拖动滚动条(或键盘移动)时实时渲染可视区数据。全部数据可以放在内存中,也可以放到SQLite中。
对WPF不太了解,但使用内置控件时可以考虑取消双向绑定(不需要编辑数据时)和数据变化监听(不用实时刷新时)。

Adming | 园豆:123 (初学一级) | 2022-09-09 09:36

可行,就是实现起来有些复杂

支持(0) 反对(0) 会长 | 园豆:11840 (专家六级) | 2022-09-09 14:27

这个业务还真不好拆分

简单来说,是个工控方面的数据显示控件。数据列分为两大类,一类是固定的必须有的数据,不多,也就20几个,象序号、采样时间、电流、电压、温度、功率之类的。另一类是动态的,比如实际运行时,接了10个电池,每个电池20个电芯,每个电芯有电压、温度两个量,这样就有10*20*2=400个量,再加上统计出来的单体电芯最高电压、最低电压、最高温度、最低温度,就是404个。

最好的方式就是显示固定数据之后,再加上最高/最低的电压和温度,另外400个就不显示了。但那400个信号,其实都没差别,不好分哪个重要哪个次要。

支持(0) 反对(0) 血狼一族 | 园豆:60 (初学一级) | 2022-09-13 11:40

@血狼一族: 理解,我上面说的我们那个web端也是这样的。

支持(0) 反对(0) Adming | 园豆:123 (初学一级) | 2022-09-13 11:50
0

5w行不过分,应该现在的机器5w个粒子60FPS都没问题。
桌面端的意义正在于此,不然用什么桌面端,用网页做就行了。

10多年前别个c#绘制的实时曲线都是几十万个点。

实时的话无非就是内存绘制而已,如果非即时无非就是loading或者自行绘制进行优化。

这里说一个类似简单办法,直接绘制成图片(内存),然后贴到控件上去。当然也可以通过处理滚动等等方式处理。第一种方法最简单,代码最少。

花飘水流兮 | 园豆:13331 (专家六级) | 2022-09-11 01:23

做成图版帖上去?

要怎么搞,给个思路!

另外,如果做成帖图,那些行的选择、选中行之后,按键盘上下键移动行,那些还能支持吗?

支持(0) 反对(0) 血狼一族 | 园豆:60 (初学一级) | 2022-09-13 11:31

另外,5W行确实不过份,就算是有10W行,ListView 也能显示出来,不算怎么卡。

但是特么有800个列啊!!!!

这么多列的情况下,别说5W行了,5千行都卡得不行!

支持(0) 反对(0) 血狼一族 | 园豆:60 (初学一级) | 2022-09-13 11:33

@血狼一族: 光显示出来应该问题不大,关键是他这个也应该需要实时更新的吧!难度还是不小哦。
另外,参考一下Excel/WPS表格,800列表、10W数据也够呛。

听说,微软内部office也试着用.NET来重写,最后性能很不好放弃了,现在都只是套壳。
如果是这样的话,Excel都卡的数据量,c#/WPF再怎么优化恐怕也是枉然哦。

支持(0) 反对(0) Adming | 园豆:123 (初学一级) | 2022-09-13 12:07
0

里面放个WEBVIEW,用网页显示

LiveCoding | 园豆:373 (菜鸟二级) | 2022-09-29 18:33
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册