{"id":108154,"date":"2026-09-21T01:13:27","date_gmt":"2026-09-20T17:13:27","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/108154.html"},"modified":"2026-09-21T01:13:27","modified_gmt":"2026-09-20T17:13:27","slug":"wpf-%e9%ab%98%e6%80%a7%e8%83%bd%e6%87%92%e5%8a%a0%e8%bd%bd%e6%8e%a7%e4%bb%b6-lazydatagrid-lazylistbox-%e5%ae%9e%e7%8e%b0%e4%b8%8e%e8%b8%a9%e5%9d%91%e5%85%a8%e5%a4%8d%e7%9b%98","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/108154.html","title":{"rendered":"WPF \u9ad8\u6027\u80fd\u61d2\u52a0\u8f7d\u63a7\u4ef6 LazyDataGrid \/ LazyListBox \u5b9e\u73b0\u4e0e\u8e29\u5751\u5168\u590d\u76d8"},"content":{"rendered":"<h3>\u4e00\u3001\u524d\u8a00&#xff1a;WPF \u5927\u6570\u636e\u5217\u8868\u7684\u901a\u7528\u75db\u70b9<\/h3>\n<p>\u5728 WPF \u9879\u76ee\u4e2d&#xff0c;\u76f4\u63a5\u7ed9 DataGrid \/ ListBox \u7ed1\u5b9a\u51e0\u4e07\u3001\u5341\u51e0\u4e07\u6761\u6570\u636e&#xff0c;\u4f1a\u51fa\u73b0\u4e25\u91cd\u95ee\u9898&#xff1a;<\/p>\n<ul>\n<li>\n<p>UI \u5361\u6b7b\u3001\u9996\u6b21\u6e32\u67d3\u6781\u6162<\/p>\n<\/li>\n<li>\n<p>\u63a7\u4ef6\u521d\u59cb\u5316\u963b\u585e\u3001\u7a97\u53e3\u5361\u987f<\/p>\n<\/li>\n<li>\n<p>\u539f\u751f\u865a\u62df\u5316\u5728\u590d\u6742\u6a21\u677f\u3001\u5206\u7ec4\u3001\u5217\u81ea\u9002\u5e94\u573a\u666f\u4e0b\u5931\u6548<\/p>\n<\/li>\n<li>\n<p>\u4e1a\u52a1\u5c42\u9700\u8981\u5168\u91cf\u52a0\u8f7d\u6570\u636e&#xff0c;\u65e0\u6cd5\u505a\u5230\u6eda\u52a8\u6309\u9700\u6e32\u67d3<\/p>\n<\/li>\n<\/ul>\n<p>\u884c\u4e1a\u5e38\u89c4\u65b9\u6848&#xff1a;\u524d\u7aef\u5206\u9875 \/ \u540e\u7aef\u5206\u9875&#xff0c;\u4f46\u5f88\u591a\u684c\u9762\u7aef\u4e1a\u52a1\u9700\u8981\u5168\u91cf\u62ff\u5230\u5185\u5b58\u3001\u524d\u7aef\u6eda\u52a8\u61d2\u52a0\u8f7d\u3002<\/p>\n<p>\u4e3a\u6b64&#xff0c;\u6211\u4eec\u4ece\u96f6\u5b9e\u73b0\u4e86\u4e00\u5957\u7eaf\u524d\u7aef\u3001\u65e0\u4f9d\u8d56\u3001\u9ad8\u6027\u80fd\u3001\u53ef\u590d\u7528\u7684\u61d2\u52a0\u8f7d\u63a7\u4ef6&#xff1a;<\/p>\n<ul>\n<li>\n<p>LazyDataGrid&#xff1a;\u9002\u914d DataGrid \u8868\u683c\u573a\u666f<\/p>\n<\/li>\n<li>\n<p>LazyListBox&#xff1a;\u9002\u914d ListBox \u5217\u8868\u573a\u666f<\/p>\n<\/li>\n<\/ul>\n<p>\u5f7b\u5e95\u89e3\u51b3 WPF \u5927\u6570\u636e\u5217\u8868\u5361\u987f\u3001\u5168\u91cf\u6e32\u67d3\u5361\u6b7b\u3001\u4e8c\u6b21\u5237\u65b0\u5931\u6548\u7b49\u7ecf\u5178\u95ee\u9898\u3002<\/p>\n<h3>\u4e8c\u3001\u6280\u672f\u6f14\u8fdb\u590d\u76d8&#xff08;\u5173\u952e\u8e29\u5751\u8bb0\u5f55&#xff09;<\/h3>\n<p>\u672c\u6b21\u6700\u7ec8\u7248\u672c\u7ecf\u5386\u4e86 3 \u8f6e\u67b6\u6784\u8fed\u4ee3&#xff0c;\u6bcf\u4e00\u8f6e\u90fd\u89e3\u51b3\u4e00\u4e2a\u5e95\u5c42 WPF \u7ed1\u5b9a\u5751&#xff0c;\u975e\u5e38\u503c\u5f97\u603b\u7ed3\u3002<\/p>\n<h4>1&#xff09;\u521d\u4ee3\u65b9\u6848&#xff1a;\u9644\u52a0\u5c5e\u6027 AttachedProperty \u61d2\u52a0\u8f7d<\/h4>\n<p>\u6700\u521d\u91c7\u7528\u9759\u6001\u9644\u52a0\u5c5e\u6027\u5b9e\u73b0\u61d2\u52a0\u8f7d\u903b\u8f91&#xff0c;\u4f18\u70b9\u662f\u4fb5\u5165\u4f4e\u3001\u65e0\u9700\u81ea\u5b9a\u4e49\u63a7\u4ef6\u3002<\/p>\n<p>\u81f4\u547d\u95ee\u9898&#xff08;WPF \u5e95\u5c42BUG&#xff09;&#xff1a;<\/p>\n<p>\u9644\u52a0\u5c5e\u6027\u7ed1\u5b9a&#xff0c;\u5728\u6570\u636e\u6e90\u6574\u4f53\u66ff\u6362 new ObservableCollection \u65f6&#xff0c;\u4e0d\u4f1a\u81ea\u52a8\u89e6\u53d1 DP \u53d8\u66f4\u56de\u8c03\u3002<\/p>\n<p>\u73b0\u8c61&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u7b2c\u4e00\u6b21\u7ed1\u5b9a\u6570\u636e\u6b63\u5e38<\/p>\n<\/li>\n<li>\n<p>\u7b2c\u4e8c\u6b21\u8d4b\u503c\u65b0\u96c6\u5408&#xff0c;PropertyChanged \u89e6\u53d1&#xff0c;\u4f46\u9644\u52a0\u5c5e\u6027 DP \u4e0d\u66f4\u65b0<\/p>\n<\/li>\n<\/ul>\n<p>\u539f\u56e0&#xff1a;WPF \u9644\u52a0\u5c5e\u6027\u7ed1\u5b9a\u7684\u66f4\u65b0\u4f18\u5148\u7ea7\u4f4e\u4e8e\u666e\u901a DP&#xff0c;\u975e\u53ef\u89c6\u5316\u6811\u5bf9\u8c61\u7ed1\u5b9a\u5b58\u5728\u901a\u77e5\u4e22\u5931\u3002<\/p>\n<h4>2&#xff09;\u8fed\u4ee3\u65b9\u6848&#xff1a;Behavior \u884c\u4e3a\u5c01\u88c5<\/h4>\n<p>\u5c06\u903b\u8f91\u8fc1\u79fb\u5230 Behavior&lt;Control&gt;&#xff0c;\u7ed3\u6784\u66f4\u4f18\u96c5\u3001\u751f\u547d\u5468\u671f\u66f4\u89c4\u8303\u3002<\/p>\n<p>\u4f9d\u7136\u5b58\u5728\u540c\u6b3e\u5751&#xff1a;<\/p>\n<p>Behavior \u5c5e\u4e8e Freezable \u5bf9\u8c61&#xff0c;\u4e0d\u5728\u53ef\u89c6\u5316\u6811\u5185&#xff0c;DP \u7ed1\u5b9a\u53d8\u66f4\u901a\u77e5\u540c\u6837\u4f1a\u4e22\u5931\u3002<\/p>\n<p>\u4e8c\u6b21\u66ff\u6362\u6570\u636e\u6e90\u4f9d\u7136\u4e0d\u5237\u65b0&#xff0c;\u65e0\u6cd5\u6839\u6cbb\u3002<\/p>\n<h4>3&#xff09;\u6700\u7ec8\u7a33\u5b9a\u65b9\u6848&#xff1a;\u7ee7\u627f\u539f\u751f\u63a7\u4ef6 &#043; \u666e\u901a DependencyProperty<\/h4>\n<p>\u5f7b\u5e95\u653e\u5f03\u9644\u52a0\u5c5e\u6027\u3001\u653e\u5f03 Behavior \u7ed1\u5b9a&#xff0c;\u91c7\u7528\u81ea\u5b9a\u4e49\u63a7\u4ef6\u7ee7\u627f\u539f\u751f\u63a7\u4ef6\u7684\u67b6\u6784&#xff1a;<\/p>\n<ul>\n<li>\n<p>LazyDataGrid : DataGrid<\/p>\n<\/li>\n<li>\n<p>LazyListBox : ListBox<\/p>\n<\/li>\n<\/ul>\n<p>\u6838\u5fc3\u4f18\u52bf&#xff1a;\u81ea\u5b9a\u4e49\u63a7\u4ef6\u5c5e\u4e8e\u53ef\u89c6\u5316\u6811\u539f\u751f\u63a7\u4ef6&#xff0c;\u6ce8\u518c\u7684\u666e\u901a DependencyProperty 100% \u6b63\u5e38\u89e6\u53d1\u53d8\u66f4\u56de\u8c03&#xff0c;\u65e0\u8bba\u591a\u5c11\u6b21\u66ff\u6362\u6570\u636e\u6e90&#xff0c;\u90fd\u80fd\u81ea\u52a8 Reset \u5237\u65b0\u3002\u81f3\u6b64&#xff0c;\u6240\u6709\u4e8c\u6b21\u66f4\u65b0\u5931\u6548\u3001\u7ed1\u5b9a\u4e0d\u5237\u65b0\u95ee\u9898\u5f7b\u5e95\u6839\u6cbb\u3002<\/p>\n<h3>\u4e09\u3001\u63a7\u4ef6\u6574\u4f53\u67b6\u6784\u8bbe\u8ba1<\/h3>\n<h4>1&#xff09;\u6838\u5fc3\u8bbe\u8ba1\u601d\u60f3<\/h4>\n<p>\u6570\u636e\u53cc\u5c42\u5206\u79bb&#xff0c;\u4ece\u6839\u6e90\u89e3\u51b3\u5927\u6570\u636e\u6e32\u67d3\u5361\u987f&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5168\u91cf\u6570\u636e\u6e90 AllItems&#xff1a;ViewModel \u7ed1\u5b9a\u7684\u5b8c\u6574\u539f\u59cb\u96c6\u5408&#xff08;\u51e0\u4e07\/\u5341\u51e0\u4e07\u6761&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u53ef\u89c6\u6570\u636e\u6e90 VisibleItems&#xff1a;\u63a7\u4ef6\u5185\u90e8\u5b50\u96c6&#xff0c;\u771f\u6b63\u7ed1\u5b9a\u5230 ItemsSource \u7528\u4e8eUI\u6e32\u67d3<\/p>\n<\/li>\n<\/ul>\n<p>UI \u6c38\u8fdc\u53ea\u6e32\u67d3\u53ef\u89c6\u533a\u57df &#043; \u9884\u52a0\u8f7d\u533a\u57df&#xff0c;\u675c\u7edd\u4e00\u6b21\u6027\u6e32\u67d3\u5168\u90e8\u6570\u636e&#xff0c;\u6781\u81f4\u4f18\u5316\u6e32\u67d3\u6027\u80fd\u3002<\/p>\n<h4>2&#xff09;\u6838\u5fc3\u80fd\u529b<\/h4>\n<ul>\n<li>\n<p>\u81ea\u52a8\u67e5\u627e\u63a7\u4ef6\u5185\u90e8 ScrollViewer&#xff0c;\u65e0\u9700\u624b\u52a8\u9002\u914d\u6a21\u677f<\/p>\n<\/li>\n<li>\n<p>\u81ea\u52a8\u6d4b\u91cf\u884c\u9ad8\/\u9879\u9ad8&#xff0c;\u65e0\u9700\u624b\u52a8\u56fa\u5b9a\u9ad8\u5ea6&#xff0c;\u9002\u914d\u4efb\u610fItemTemplate<\/p>\n<\/li>\n<li>\n<p>\u6839\u636e\u7a97\u53e3\u89c6\u53e3\u5927\u5c0f\u52a8\u6001\u8ba1\u7b97\u6bcf\u9875\u6570\u636e\u91cf&#xff0c;\u81ea\u9002\u5e94\u7a97\u53e3\u7f29\u653e<\/p>\n<\/li>\n<li>\n<p>\u652f\u6301\u81ea\u5b9a\u4e49\u9884\u52a0\u8f7d\u5c4f\u5e55\u500d\u6570&#xff0c;\u5e73\u8861\u6d41\u7545\u5ea6\u4e0e\u5185\u5b58\u5360\u7528<\/p>\n<\/li>\n<li>\n<p>\u6eda\u52a8\u5230\u5e95\u90e8\u81ea\u52a8\u7eed\u9875&#xff0c;\u65e0\u611f\u61d2\u52a0\u8f7d<\/p>\n<\/li>\n<li>\n<p>\u6570\u636e\u6e90\u6574\u4f53\u66ff\u6362\u81ea\u52a8\u91cd\u7f6e\u5206\u9875&#xff0c;\u65e0\u9700\u624b\u52a8\u5237\u65b0<\/p>\n<\/li>\n<li>\n<p>\u63a7\u4ef6\u5c3a\u5bf8\u53d8\u5316\u81ea\u52a8\u91cd\u7b97\u5206\u9875&#xff0c;\u9002\u914d\u7a97\u53e3\u7f29\u653e<\/p>\n<\/li>\n<li>\n<p>\u5b8c\u6574\u751f\u547d\u5468\u671f\u4e8b\u4ef6\u89e3\u7ed1&#xff0c;\u675c\u7edd\u5185\u5b58\u6cc4\u6f0f<\/p>\n<\/li>\n<\/ul>\n<h4>3&#xff09;\u53ef\u914d\u7f6e\u53c2\u6570\u8bf4\u660e<\/h4>\n<table>\n<tr>\n<p>\u5c5e\u6027<\/p>\n<p>\u7c7b\u578b<\/p>\n<p>\u8bf4\u660e<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td colspan=\"1\" rowspan=\"1\">\n<p>IsEnabled<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p>bool<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p>\u5f00\u542f\/\u5173\u95ed\u61d2\u52a0\u8f7d&#xff0c;\u5173\u95ed\u540e\u5b8c\u5168\u6062\u590d\u539f\u751f\u63a7\u4ef6\u6e32\u67d3\u903b\u8f91<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"1\">\n<p>PreloadScreen<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p>double<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p>\u9884\u52a0\u8f7d\u5c4f\u5e55\u500d\u6570&#xff0c;\u9ed8\u8ba41.2\u500d\u53ef\u89c6\u533a\u57df&#xff0c;\u6570\u503c\u8d8a\u5927\u9884\u52a0\u8f7d\u8d8a\u591a<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"1\">\n<p>AllItems<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p>IList<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p>ViewModel\u7ed1\u5b9a\u7684\u5168\u91cf\u539f\u59cb\u6570\u636e\u6e90&#xff0c;\u652f\u6301\u4efb\u610fIList\u96c6\u5408<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u56db\u3001\u63a7\u4ef6\u5de5\u4f5c\u6d41\u7a0b<\/h3>\n<li>\n<p>\u63a7\u4ef6\u52a0\u8f7d\u5b8c\u6210&#xff1a;\u81ea\u52a8\u904d\u5386\u53ef\u89c6\u5316\u6811\u67e5\u627e\u5185\u90e8 ScrollViewer&#xff0c;\u7ed1\u5b9a\u6eda\u52a8\u76d1\u542c\u4e8b\u4ef6<\/p>\n<\/li>\n<li>\n<p>\u5bb9\u5668\u751f\u6210\u5b8c\u6210&#xff1a;\u81ea\u52a8\u6d4b\u91cf\u9996\u884c\/\u9996\u9879\u771f\u5b9e\u9ad8\u5ea6&#xff0c;\u9002\u914d\u81ea\u5b9a\u4e49\u6a21\u677f<\/p>\n<\/li>\n<li>\n<p>\u52a8\u6001\u8ba1\u7b97\u5206\u9875&#xff1a;\u901a\u8fc7\u89c6\u53e3\u9ad8\u5ea6\u3001\u5355\u9879\u9ad8\u5ea6\u3001\u9884\u52a0\u8f7d\u500d\u6570\u8ba1\u7b97\u5355\u9875\u52a0\u8f7d\u91cf<\/p>\n<\/li>\n<li>\n<p>\u9996\u6b21\u521d\u59cb\u5316&#xff1a;\u52a0\u8f7d\u7b2c\u4e00\u5c4f\u6570\u636e&#xff0c;\u5b8c\u6210\u521d\u59cb\u6e32\u67d3<\/p>\n<\/li>\n<li>\n<p>\u6eda\u52a8\u76d1\u542c\u52a0\u8f7d&#xff1a;\u6eda\u52a8\u8ddd\u79bb\u5e95\u90e8\u4e0d\u8db3\u534a\u5c4f&#xff0c;\u81ea\u52a8\u52a0\u8f7d\u4e0b\u4e00\u9875\u6570\u636e<\/p>\n<\/li>\n<li>\n<p>\u6570\u636e\u6e90\u53d8\u66f4\u54cd\u5e94&#xff1a;\u66ff\u6362AllItems\u6570\u636e\u6e90\u65f6&#xff0c;\u81ea\u52a8\u6e05\u7a7a\u65e7\u6570\u636e\u3001\u91cd\u7f6e\u5206\u9875\u3001\u91cd\u65b0\u52a0\u8f7d<\/p>\n<\/li>\n<h3>\u4e94\u3001\u4e24\u6b3e\u63a7\u4ef6\u533a\u522b\u4e0e\u9002\u7528\u573a\u666f<\/h3>\n<h4>1&#xff09;LazyDataGrid<\/h4>\n<ul>\n<li>\n<p>\u7ee7\u627f\u81ea\u539f\u751f DataGrid&#xff0c;\u4fdd\u7559\u6240\u6709\u8868\u683c\u539f\u751f\u7279\u6027<\/p>\n<\/li>\n<li>\n<p>\u81ea\u52a8\u6d4b\u91cf DataGridRow \u884c\u9ad8&#xff0c;\u9002\u914d\u591a\u5217\u8868\u683c\u573a\u666f<\/p>\n<\/li>\n<li>\n<p>\u9002\u7528\u573a\u666f&#xff1a;\u591a\u5217\u6570\u636e\u5c55\u793a\u3001\u9700\u8981\u8868\u5934\u3001\u6392\u5e8f\u3001\u7b5b\u9009\u3001\u5355\u5143\u683c\u4ea4\u4e92\u7684\u4e1a\u52a1\u8868\u683c<\/p>\n<\/li>\n<\/ul>\n<h4>2&#xff09;LazyListBox<\/h4>\n<ul>\n<li>\n<p>\u7ee7\u627f\u81ea\u539f\u751f ListBox&#xff0c;\u4fdd\u7559\u6240\u6709\u5217\u8868\u539f\u751f\u7279\u6027<\/p>\n<\/li>\n<li>\n<p>\u81ea\u52a8\u6d4b\u91cf ListBoxItem \u9879\u9ad8&#xff0c;\u9002\u914d\u4efb\u610f\u81ea\u5b9a\u4e49ItemTemplate<\/p>\n<\/li>\n<li>\n<p>\u9002\u7528\u573a\u666f&#xff1a;\u5355\u884c\u5217\u8868\u3001\u65e5\u5fd7\u5217\u8868\u3001\u6d88\u606f\u5217\u8868\u3001\u7b80\u5355\u6761\u76ee\u6d41\u5f0f\u5c55\u793a<\/p>\n<\/li>\n<\/ul>\n<h4>\u5171\u540c\u6838\u5fc3\u7279\u6027<\/h4>\n<ul>\n<li>\n<p>\u5b8c\u5168\u4fdd\u7559\u539f\u751f\u63a7\u4ef6\u6240\u6709\u529f\u80fd&#xff1a;\u6a21\u677f\u3001\u6837\u5f0f\u3001\u9009\u4e2d\u3001\u4ea4\u4e92\u3001\u4e8b\u4ef6<\/p>\n<\/li>\n<li>\n<p>\u7ed1\u5b9a\u7a33\u5b9a&#xff0c;\u5f7b\u5e95\u89e3\u51b3\u9644\u52a0\u5c5e\u6027\/Behavior\u7ed1\u5b9a\u5931\u6548\u7384\u5b66\u95ee\u9898<\/p>\n<\/li>\n<li>\n<p>\u652f\u6301\u5341\u4e07\u7ea7\u5927\u6570\u636e\u6d41\u7545\u6eda\u52a8&#xff0c;\u65e0\u5361\u987f\u3001\u65e0\u5361\u6b7b<\/p>\n<\/li>\n<\/ul>\n<h3>\u516d\u3001\u5b8c\u6574\u6e90\u7801&#xff08;\u53ef\u76f4\u63a5\u843d\u5730\u4f7f\u7528&#xff09;<\/h3>\n<h4>6.1 \u516c\u5171\u5b9e\u4f53\u6a21\u578b ItemModel<\/h4>\n<p>\/\/\/ &lt;summary&gt;<br \/>\n\/\/\/ \u901a\u7528\u5217\u8868\u6d4b\u8bd5\u5b9e\u4f53\u6a21\u578b<br \/>\n\/\/\/ &lt;\/summary&gt;<br \/>\npublic class ItemModel<br \/>\n{<br \/>\n    public int Id { get; set; }<br \/>\n    public string Name { get; set; }<br \/>\n}<\/p>\n<h4>6.2 \u6807\u51c6 MVVM ViewModel<\/h4>\n<p>using System;<br \/>\nusing System.Collections.ObjectModel;<br \/>\nusing System.ComponentModel;<br \/>\nusing System.Runtime.CompilerServices;<\/p>\n<p>\/\/\/ &lt;summary&gt;<br \/>\n\/\/\/ \u901a\u7528\u61d2\u52a0\u8f7d\u5217\u8868ViewModel&#xff0c;\u7eafMVVM\u65e0\u5197\u4f59\u4ee3\u7801<br \/>\n\/\/\/ &lt;\/summary&gt;<br \/>\npublic class LazyListViewModel : INotifyPropertyChanged<br \/>\n{<br \/>\n    private ObservableCollection&lt;ItemModel&gt; _items;<\/p>\n<p>    \/\/\/ &lt;summary&gt;<br \/>\n    \/\/\/ \u5168\u91cf\u7ed1\u5b9a\u6570\u636e\u6e90&#xff0c;\u652f\u6301\u591a\u6b21\u66ff\u6362\u5237\u65b0<br \/>\n    \/\/\/ &lt;\/summary&gt;<br \/>\n    public ObservableCollection&lt;ItemModel&gt; Items<br \/>\n    {<br \/>\n        get &#061;&gt; _items;<br \/>\n        set<br \/>\n        {<br \/>\n            _items &#061; value;<br \/>\n            OnPropertyChanged();<br \/>\n        }<br \/>\n    }<\/p>\n<p>    public event PropertyChangedEventHandler PropertyChanged;<\/p>\n<p>    protected void OnPropertyChanged([CallerMemberName] string propertyName &#061; null)<br \/>\n    {<br \/>\n        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));<br \/>\n    }<br \/>\n}<\/p>\n<h4>6.3 LazyDataGrid \u5b8c\u6574\u6e90\u7801<\/h4>\n<p>using System;<br \/>\nusing System.Collections;<br \/>\nusing System.Collections.ObjectModel;<br \/>\nusing System.Windows;<br \/>\nusing System.Windows.Controls;<br \/>\nusing System.Windows.Media;<\/p>\n<p>namespace WpfAttachedLazyLoad<br \/>\n{<br \/>\n    public class LazyDataGrid : DataGrid<br \/>\n    {<br \/>\n        #region DependencyProperties<br \/>\n        public static readonly DependencyProperty IsEnabledProperty &#061;<br \/>\n            DependencyProperty.Register(<br \/>\n                nameof(IsEnabled),<br \/>\n                typeof(bool),<br \/>\n                typeof(LazyDataGrid),<br \/>\n                new PropertyMetadata(false, OnIsEnabledChanged));<\/p>\n<p>        public bool IsEnabled<br \/>\n        {<br \/>\n            get &#061;&gt; (bool)GetValue(IsEnabledProperty);<br \/>\n            set &#061;&gt; SetValue(IsEnabledProperty, value);<br \/>\n        }<\/p>\n<p>        public static readonly DependencyProperty PreloadScreenProperty &#061;<br \/>\n            DependencyProperty.Register(<br \/>\n                nameof(PreloadScreen),<br \/>\n                typeof(double),<br \/>\n                typeof(LazyDataGrid),<br \/>\n                new PropertyMetadata(1.2));<\/p>\n<p>        public double PreloadScreen<br \/>\n        {<br \/>\n            get &#061;&gt; (double)GetValue(PreloadScreenProperty);<br \/>\n            set &#061;&gt; SetValue(PreloadScreenProperty, value);<br \/>\n        }<\/p>\n<p>        \/\/\/ &lt;summary&gt;\u5b8c\u6574\u539f\u59cb\u6570\u636e\u6e90&#xff0c;ViewModel\u7ed1\u5b9a\u5165\u53e3&lt;\/summary&gt;<br \/>\n        public static readonly DependencyProperty AllItemsProperty &#061;<br \/>\n            DependencyProperty.Register(<br \/>\n                nameof(AllItems),<br \/>\n                typeof(IList),<br \/>\n                typeof(LazyDataGrid),<br \/>\n                new PropertyMetadata(null, OnAllItemsChanged));<\/p>\n<p>        public IList AllItems<br \/>\n        {<br \/>\n            get &#061;&gt; (IList)GetValue(AllItemsProperty);<br \/>\n            set &#061;&gt; SetValue(AllItemsProperty, value);<br \/>\n        }<\/p>\n<p>        \/\/\/ &lt;summary&gt;\u5185\u90e8\u53ef\u89c6\u5b50\u96c6&#xff0c;\u771f\u6b63\u7ed1\u5b9a\u5230ItemsSource\u7528\u4e8e\u6e32\u67d3&lt;\/summary&gt;<br \/>\n        private static readonly DependencyProperty VisibleItemsProperty &#061;<br \/>\n            DependencyProperty.Register(<br \/>\n                nameof(VisibleItems),<br \/>\n                typeof(ObservableCollection&lt;object&gt;),<br \/>\n                typeof(LazyDataGrid),<br \/>\n                new PropertyMetadata(null));<\/p>\n<p>        private ObservableCollection&lt;object&gt; VisibleItems<br \/>\n        {<br \/>\n            get &#061;&gt; (ObservableCollection&lt;object&gt;)GetValue(VisibleItemsProperty);<br \/>\n            set &#061;&gt; SetValue(VisibleItemsProperty, value);<br \/>\n        }<br \/>\n        #endregion<\/p>\n<p>        #region Private Fields &amp; \u4e0a\u4e0b\u6587<br \/>\n        private LazyLoadContext _lazyCtx;<br \/>\n        private ScrollViewer _scrollViewer;<\/p>\n<p>        \/\/\/ &lt;summary&gt;\u61d2\u52a0\u8f7d\u4e0a\u4e0b\u6587\u7f13\u5b58&lt;\/summary&gt;<br \/>\n        private class LazyLoadContext<br \/>\n        {<br \/>\n            public int PageSize { get; set; }<br \/>\n            public int LoadedItemIndex { get; set; }<br \/>\n            public bool IsLoading { get; set; }<br \/>\n            public double MeasuredRowHeight { get; set; }<br \/>\n        }<br \/>\n        #endregion<\/p>\n<p>        #region \u4f9d\u8d56\u5c5e\u6027\u53d8\u66f4\u56de\u8c03<br \/>\n        private static void OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)<br \/>\n        {<br \/>\n            var grid &#061; d as LazyDataGrid;<br \/>\n            bool enable &#061; (bool)e.NewValue;<br \/>\n            if (enable)<br \/>\n                grid.AttachLazy();<br \/>\n            else<br \/>\n                grid.DetachLazy();<br \/>\n        }<\/p>\n<p>        private static void OnAllItemsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)<br \/>\n        {<br \/>\n            var grid &#061; d as LazyDataGrid;<br \/>\n            if (!grid.IsEnabled) return;<br \/>\n            \/\/ \u6570\u636e\u6e90\u6574\u4f53\u66ff\u6362&#xff0c;\u81ea\u52a8\u91cd\u7f6e\u5206\u9875<br \/>\n            grid.Reset();<br \/>\n        }<br \/>\n        #endregion<\/p>\n<p>        #region \u61d2\u52a0\u8f7d\u6302\u8f7d\/\u5378\u8f7d\u751f\u547d\u5468\u671f<br \/>\n        private void AttachLazy()<br \/>\n        {<br \/>\n            if (_lazyCtx !&#061; null) return;<\/p>\n<p>            _lazyCtx &#061; new LazyLoadContext();<br \/>\n            VisibleItems &#061; new ObservableCollection&lt;object&gt;();<br \/>\n            ItemsSource &#061; VisibleItems;<\/p>\n<p>            \/\/ \u7ed1\u5b9a\u751f\u547d\u5468\u671f\u4e8b\u4ef6<br \/>\n            Loaded &#043;&#061; Host_Loaded;<br \/>\n            Unloaded &#043;&#061; Host_Unloaded;<br \/>\n            SizeChanged &#043;&#061; Host_SizeChanged;<br \/>\n            ItemContainerGenerator.StatusChanged &#043;&#061; Generator_StatusChanged;<br \/>\n        }<\/p>\n<p>        private void DetachLazy()<br \/>\n        {<br \/>\n            \/\/ \u89e3\u7ed1\u6eda\u52a8\u4e8b\u4ef6&#xff0c;\u9632\u6b62\u5185\u5b58\u6cc4\u6f0f<br \/>\n            if (_scrollViewer !&#061; null)<br \/>\n            {<br \/>\n                _scrollViewer.ScrollChanged -&#061; ScrollViewer_ScrollChanged;<br \/>\n                _scrollViewer &#061; null;<br \/>\n            }<\/p>\n<p>            \/\/ \u89e3\u7ed1\u6240\u6709\u751f\u547d\u5468\u671f\u4e8b\u4ef6<br \/>\n            Loaded -&#061; Host_Loaded;<br \/>\n            Unloaded -&#061; Host_Unloaded;<br \/>\n            SizeChanged -&#061; Host_SizeChanged;<br \/>\n            ItemContainerGenerator.StatusChanged -&#061; Generator_StatusChanged;<\/p>\n<p>            _lazyCtx &#061; null;<br \/>\n            VisibleItems &#061; null;<br \/>\n            ItemsSource &#061; null;<br \/>\n        }<br \/>\n        #endregion<\/p>\n<p>        #region \u9012\u5f52\u67e5\u627e\u5185\u90e8ScrollViewer<br \/>\n        private ScrollViewer FindScrollViewer(DependencyObject parent)<br \/>\n        {<br \/>\n            if (parent &#061;&#061; null) return null;<br \/>\n            if (parent is ScrollViewer sv) return sv;<\/p>\n<p>            int childCount &#061; VisualTreeHelper.GetChildrenCount(parent);<br \/>\n            for (int i &#061; 0; i &lt; childCount; i&#043;&#043;)<br \/>\n            {<br \/>\n                var child &#061; VisualTreeHelper.GetChild(parent, i);<br \/>\n                var result &#061; FindScrollViewer(child);<br \/>\n                if (result !&#061; null) return result;<br \/>\n            }<br \/>\n            return null;<br \/>\n        }<br \/>\n        #endregion<\/p>\n<p>        #region \u63a7\u4ef6\u751f\u547d\u5468\u671f\u4e8b\u4ef6<br \/>\n        private void Host_Loaded(object sender, RoutedEventArgs e)<br \/>\n        {<br \/>\n            _scrollViewer &#061; FindScrollViewer(this);<br \/>\n            if (_scrollViewer !&#061; null)<br \/>\n                _scrollViewer.ScrollChanged &#043;&#061; ScrollViewer_ScrollChanged;<\/p>\n<p>            CalcPageSize();<br \/>\n            Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(Reset));<br \/>\n        }<\/p>\n<p>        private void Host_Unloaded(object sender, RoutedEventArgs e)<br \/>\n        {<br \/>\n            if (_scrollViewer !&#061; null)<br \/>\n                _scrollViewer.ScrollChanged -&#061; ScrollViewer_ScrollChanged;<br \/>\n        }<\/p>\n<p>        private void Host_SizeChanged(object sender, SizeChangedEventArgs e)<br \/>\n        {<br \/>\n            CalcPageSize();<br \/>\n            Reset();<br \/>\n        }<\/p>\n<p>        private void Generator_StatusChanged(object sender, EventArgs e)<br \/>\n        {<br \/>\n            var gen &#061; sender as ItemContainerGenerator;<br \/>\n            if (gen &#061;&#061; null || gen.Status !&#061; GeneratorStatus.ContainersGenerated)<br \/>\n                return;<br \/>\n            if (_lazyCtx &#061;&#061; null || _lazyCtx.MeasuredRowHeight &gt; 0)<br \/>\n                return;<\/p>\n<p>            \/\/ \u81ea\u52a8\u6d4b\u91cf\u9996\u884c\u9ad8\u5ea6<br \/>\n            var firstRow &#061; gen.ContainerFromIndex(0) as DataGridRow;<br \/>\n            if (firstRow &#061;&#061; null) return;<\/p>\n<p>            double rowHeight &#061; firstRow.ActualHeight;<br \/>\n            if (rowHeight &gt; 0)<br \/>\n            {<br \/>\n                _lazyCtx.MeasuredRowHeight &#061; rowHeight;<br \/>\n                CalcPageSize();<br \/>\n                Reset();<br \/>\n            }<br \/>\n        }<br \/>\n        #endregion<\/p>\n<p>        #region \u52a8\u6001\u8ba1\u7b97\u5206\u9875\u5927\u5c0f<br \/>\n        private void CalcPageSize()<br \/>\n        {<br \/>\n            double preload &#061; PreloadScreen;<br \/>\n            double rowHeight &#061; _lazyCtx.MeasuredRowHeight &gt; 0 ? _lazyCtx.MeasuredRowHeight : 30;<\/p>\n<p>            if (_scrollViewer &#061;&#061; null || _scrollViewer.ViewportHeight &lt;&#061; 0)<br \/>\n            {<br \/>\n                _lazyCtx.PageSize &#061; 20;<br \/>\n                return;<br \/>\n            }<br \/>\n            \/\/ \u6839\u636e\u89c6\u53e3\u9ad8\u5ea6\u52a8\u6001\u8ba1\u7b97\u5355\u9875\u6570\u636e\u91cf<br \/>\n            int oneScreen &#061; (int)Math.Ceiling(_scrollViewer.ViewportHeight \/ rowHeight);<br \/>\n            _lazyCtx.PageSize &#061; (int)Math.Ceiling(oneScreen * preload);<br \/>\n        }<br \/>\n        #endregion<\/p>\n<p>        #region \u52a0\u8f7d\u4e0b\u4e00\u9875\u6570\u636e<br \/>\n        private void LoadNextPage()<br \/>\n        {<br \/>\n            if (_lazyCtx.IsLoading) return;<br \/>\n            IList source &#061; AllItems;<br \/>\n            var visible &#061; VisibleItems;<br \/>\n            if (source &#061;&#061; null || visible &#061;&#061; null || _lazyCtx.LoadedItemIndex &gt;&#061; source.Count)<br \/>\n                return;<\/p>\n<p>            _lazyCtx.IsLoading &#061; true;<br \/>\n            try<br \/>\n            {<br \/>\n                int take &#061; Math.Min(_lazyCtx.PageSize, source.Count &#8211; _lazyCtx.LoadedItemIndex);<br \/>\n                for (int i &#061; 0; i &lt; take; i&#043;&#043;)<br \/>\n                {<br \/>\n                    visible.Add(source[_lazyCtx.LoadedItemIndex &#043; i]);<br \/>\n                }<br \/>\n                _lazyCtx.LoadedItemIndex &#043;&#061; take;<br \/>\n            }<br \/>\n            finally<br \/>\n            {<br \/>\n                _lazyCtx.IsLoading &#061; false;<br \/>\n            }<br \/>\n        }<br \/>\n        #endregion<\/p>\n<p>        #region \u6eda\u52a8\u9884\u52a0\u8f7d\u903b\u8f91<br \/>\n        private void ScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e)<br \/>\n        {<br \/>\n            if (_lazyCtx &#061;&#061; null || _lazyCtx.IsLoading) return;<br \/>\n            CalcPageSize();<\/p>\n<p>            IList source &#061; AllItems;<br \/>\n            if (source &#061;&#061; null || _lazyCtx.LoadedItemIndex &gt;&#061; source.Count) return;<\/p>\n<p>            double rowHeight &#061; _lazyCtx.MeasuredRowHeight &gt; 0 ? _lazyCtx.MeasuredRowHeight : 30;<br \/>\n            double remain &#061; _scrollViewer.ExtentHeight &#8211; (_scrollViewer.VerticalOffset &#043; _scrollViewer.ViewportHeight);<br \/>\n            \/\/ \u8ddd\u79bb\u5e95\u90e8\u5c0f\u4e8e\u534a\u884c\u9ad8\u5ea6&#xff0c;\u89e6\u53d1\u9884\u52a0\u8f7d<br \/>\n            if (remain &lt; rowHeight * 0.5)<br \/>\n            {<br \/>\n                LoadNextPage();<br \/>\n            }<br \/>\n        }<br \/>\n        #endregion<\/p>\n<p>        #region \u5bf9\u5916\u516c\u5f00\u91cd\u7f6e\u65b9\u6cd5<br \/>\n        public void Reset()<br \/>\n        {<br \/>\n            if (_lazyCtx &#061;&#061; null || VisibleItems &#061;&#061; null) return;<br \/>\n            IList source &#061; AllItems;<br \/>\n            if (source &#061;&#061; null) return;<\/p>\n<p>            VisibleItems.Clear();<br \/>\n            _lazyCtx.LoadedItemIndex &#061; 0;<br \/>\n            _lazyCtx.IsLoading &#061; false;<br \/>\n            LoadNextPage();<br \/>\n        }<br \/>\n        #endregion<br \/>\n    }<br \/>\n}<\/p>\n<h4>6.4 LazyListBox \u5b8c\u6574\u6e90\u7801<\/h4>\n<p>using System;<br \/>\nusing System.Collections;<br \/>\nusing System.Collections.ObjectModel;<br \/>\nusing System.Windows;<br \/>\nusing System.Windows.Controls;<br \/>\nusing System.Windows.Media;<\/p>\n<p>namespace WpfAttachedLazyLoad<br \/>\n{<br \/>\n    public class LazyListBox : ListBox<br \/>\n    {<br \/>\n        #region DependencyProperties<br \/>\n        public static readonly DependencyProperty IsEnabledProperty &#061;<br \/>\n            DependencyProperty.Register(<br \/>\n                nameof(IsEnabled),<br \/>\n                typeof(bool),<br \/>\n                typeof(LazyListBox),<br \/>\n                new PropertyMetadata(false, OnIsEnabledChanged));<\/p>\n<p>        public bool IsEnabled<br \/>\n        {<br \/>\n            get &#061;&gt; (bool)GetValue(IsEnabledProperty);<br \/>\n            set &#061;&gt; SetValue(IsEnabledProperty, value);<br \/>\n        }<\/p>\n<p>        public static readonly DependencyProperty PreloadScreenProperty &#061;<br \/>\n            DependencyProperty.Register(<br \/>\n                nameof(PreloadScreen),<br \/>\n                typeof(double),<br \/>\n                typeof(LazyListBox),<br \/>\n                new PropertyMetadata(1.2));<\/p>\n<p>        public double PreloadScreen<br \/>\n        {<br \/>\n            get &#061;&gt; (double)GetValue(PreloadScreenProperty);<br \/>\n            set &#061;&gt; SetValue(PreloadScreenProperty, value);<br \/>\n        }<\/p>\n<p>        \/\/\/ &lt;summary&gt;\u5b8c\u6574\u539f\u59cb\u6570\u636e\u6e90&#xff0c;ViewModel\u7ed1\u5b9a\u5165\u53e3&lt;\/summary&gt;<br \/>\n        public static readonly DependencyProperty AllItemsProperty &#061;<br \/>\n            DependencyProperty.Register(<br \/>\n                nameof(AllItems),<br \/>\n                typeof(IList),<br \/>\n                typeof(LazyListBox),<br \/>\n                new PropertyMetadata(null, OnAllItemsChanged));<\/p>\n<p>        public IList AllItems<br \/>\n        {<br \/>\n            get &#061;&gt; (IList)GetValue(AllItemsProperty);<br \/>\n            set &#061;&gt; SetValue(AllItemsProperty, value);<br \/>\n        }<\/p>\n<p>        \/\/\/ &lt;summary&gt;\u5185\u90e8\u53ef\u89c6\u5b50\u96c6&#xff0c;\u771f\u6b63\u7ed1\u5b9a\u5230ItemsSource\u7528\u4e8e\u6e32\u67d3&lt;\/summary&gt;<br \/>\n        private static readonly DependencyProperty VisibleItemsProperty &#061;<br \/>\n            DependencyProperty.Register(<br \/>\n                nameof(VisibleItems),<br \/>\n                typeof(ObservableCollection&lt;object&gt;),<br \/>\n                typeof(LazyListBox),<br \/>\n                new PropertyMetadata(null));<\/p>\n<p>        private ObservableCollection&lt;object&gt; VisibleItems<br \/>\n        {<br \/>\n            get &#061;&gt; (ObservableCollection&lt;object&gt;)GetValue(VisibleItemsProperty);<br \/>\n            set &#061;&gt; SetValue(VisibleItemsProperty, value);<br \/>\n        }<br \/>\n        #endregion<\/p>\n<p>        #region Private Fields &amp; \u4e0a\u4e0b\u6587<br \/>\n        private LazyLoadContext _lazyCtx;<br \/>\n        private ScrollViewer _scrollViewer;<\/p>\n<p>        \/\/\/ &lt;summary&gt;\u61d2\u52a0\u8f7d\u4e0a\u4e0b\u6587\u7f13\u5b58&lt;\/summary&gt;<br \/>\n        private class LazyLoadContext<br \/>\n        {<br \/>\n            public int PageSize { get; set; }<br \/>\n            public int LoadedItemIndex { get; set; }<br \/>\n            public bool IsLoading { get; set; }<br \/>\n            public double MeasuredItemHeight { get; set; }<br \/>\n        }<br \/>\n        #endregion<\/p>\n<p>        #region \u4f9d\u8d56\u5c5e\u6027\u53d8\u66f4\u56de\u8c03<br \/>\n        private static void OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)<br \/>\n        {<br \/>\n            var listBox &#061; d as LazyListBox;<br \/>\n            bool enable &#061; (bool)e.NewValue;<br \/>\n            if (enable)<br \/>\n                listBox.AttachLazy();<br \/>\n            else<br \/>\n                listBox.DetachLazy();<br \/>\n        }<\/p>\n<p>        private static void OnAllItemsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)<br \/>\n        {<br \/>\n            var listBox &#061; d as LazyListBox;<br \/>\n            if (!listBox.IsEnabled) return;<br \/>\n            \/\/ \u6570\u636e\u6e90\u6574\u4f53\u66ff\u6362&#xff0c;\u81ea\u52a8\u91cd\u7f6e\u5206\u9875<br \/>\n            listBox.Reset();<br \/>\n        }<br \/>\n        #endregion<\/p>\n<p>        #region \u61d2\u52a0\u8f7d\u6302\u8f7d\/\u5378\u8f7d\u751f\u547d\u5468\u671f<br \/>\n        private void AttachLazy()<br \/>\n        {<br \/>\n            if (_lazyCtx !&#061; null) return;<\/p>\n<p>            _lazyCtx &#061; new LazyLoadContext();<br \/>\n            VisibleItems &#061; new ObservableCollection&lt;object&gt;();<br \/>\n            ItemsSource &#061; VisibleItems;<\/p>\n<p>            \/\/ \u7ed1\u5b9a\u751f\u547d\u5468\u671f\u4e8b\u4ef6<br \/>\n            Loaded &#043;&#061; Host_Loaded;<br \/>\n            Unloaded &#043;&#061; Host_Unloaded;<br \/>\n            SizeChanged &#043;&#061; Host_SizeChanged;<br \/>\n            ItemContainerGenerator.StatusChanged &#043;&#061; Generator_StatusChanged;<br \/>\n        }<\/p>\n<p>        private void DetachLazy()<br \/>\n        {<br \/>\n            \/\/ \u89e3\u7ed1\u6eda\u52a8\u4e8b\u4ef6&#xff0c;\u9632\u6b62\u5185\u5b58\u6cc4\u6f0f<br \/>\n            if (_scrollViewer !&#061; null)<br \/>\n            {<br \/>\n                _scrollViewer.ScrollChanged -&#061; ScrollViewer_ScrollChanged;<br \/>\n                _scrollViewer &#061; null;<br \/>\n            }<\/p>\n<p>            \/\/ \u89e3\u7ed1\u6240\u6709\u751f\u547d\u5468\u671f\u4e8b\u4ef6<br \/>\n            Loaded -&#061; Host_Loaded;<br \/>\n            Unloaded -&#061; Host_Unloaded;<br \/>\n            SizeChanged -&#061; Host_SizeChanged;<br \/>\n            ItemContainerGenerator.StatusChanged -&#061; Generator_StatusChanged;<\/p>\n<p>            _lazyCtx &#061; null;<br \/>\n            VisibleItems &#061; null;<br \/>\n            ItemsSource &#061; null;<br \/>\n        }<br \/>\n        #endregion<\/p>\n<p>        #region \u9012\u5f52\u67e5\u627e\u5185\u90e8ScrollViewer<br \/>\n        private ScrollViewer FindScrollViewer(DependencyObject parent)<br \/>\n        {<br \/>\n            if (parent &#061;&#061; null) return null;<br \/>\n            if (parent is ScrollViewer sv) return sv;<\/p>\n<p>            int childCount &#061; VisualTreeHelper.GetChildrenCount(parent);<br \/>\n            for (int i &#061; 0; i &lt; childCount; i&#043;&#043;)<br \/>\n            {<br \/>\n                var child &#061; VisualTreeHelper.GetChild(parent, i);<br \/>\n                var result &#061; FindScrollViewer(child);<br \/>\n                if (result !&#061; null) return result;<br \/>\n            }<br \/>\n            return null;<br \/>\n        }<br \/>\n        #endregion<\/p>\n<p>        #region \u63a7\u4ef6\u751f\u547d\u5468\u671f\u4e8b\u4ef6<br \/>\n        private void Host_Loaded(object sender, RoutedEventArgs e)<br \/>\n        {<br \/>\n            _scrollViewer &#061; FindScrollViewer(this);<br \/>\n            if (_scrollViewer !&#061; null)<br \/>\n                _scrollViewer.ScrollChanged &#043;&#061; ScrollViewer_ScrollChanged;<\/p>\n<p>            CalcPageSize();<br \/>\n            Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(Reset));<br \/>\n        }<\/p>\n<p>        private void Host_Unloaded(object sender, RoutedEventArgs e)<br \/>\n        {<br \/>\n            if (_scrollViewer !&#061; null)<br \/>\n                _scrollViewer.ScrollChanged -&#061; ScrollViewer_ScrollChanged;<br \/>\n        }<\/p>\n<p>        private void Host_SizeChanged(object sender, SizeChangedEventArgs e)<br \/>\n        {<br \/>\n            CalcPageSize();<br \/>\n            Reset();<br \/>\n        }<\/p>\n<p>        private void Generator_StatusChanged(object sender, EventArgs e)<br \/>\n        {<br \/>\n            var gen &#061; sender as ItemContainerGenerator;<br \/>\n            if (gen &#061;&#061; null || gen.Status !&#061; GeneratorStatus.ContainersGenerated)<br \/>\n                return;<br \/>\n            if (_lazyCtx &#061;&#061; null || _lazyCtx.MeasuredItemHeight &gt; 0)<br \/>\n                return;<\/p>\n<p>            \/\/ \u81ea\u52a8\u6d4b\u91cf\u9996\u9879\u9ad8\u5ea6<br \/>\n            var firstItem &#061; gen.ContainerFromIndex(0) as ListBoxItem;<br \/>\n            if (firstItem &#061;&#061; null) return;<\/p>\n<p>            double itemHeight &#061; firstItem.ActualHeight;<br \/>\n            if (itemHeight &gt; 0)<br \/>\n            {<br \/>\n                _lazyCtx.MeasuredItemHeight &#061; itemHeight;<br \/>\n                CalcPageSize();<br \/>\n                Reset();<br \/>\n            }<br \/>\n        }<br \/>\n        #endregion<\/p>\n<p>        #region \u52a8\u6001\u8ba1\u7b97\u5206\u9875\u5927\u5c0f<br \/>\n        private void CalcPageSize()<br \/>\n        {<br \/>\n            double preload &#061; PreloadScreen;<br \/>\n            double itemHeight &#061; _lazyCtx.MeasuredItemHeight &gt; 0 ? _lazyCtx.MeasuredItemHeight : 30;<\/p>\n<p>            if (_scrollViewer &#061;&#061; null || _scrollViewer.ViewportHeight &lt;&#061; 0)<br \/>\n            {<br \/>\n                _lazyCtx.PageSize &#061; 20;<br \/>\n                return;<br \/>\n            }<br \/>\n            \/\/ \u6839\u636e\u89c6\u53e3\u9ad8\u5ea6\u52a8\u6001\u8ba1\u7b97\u5355\u9875\u6570\u636e\u91cf<br \/>\n            int oneScreen &#061; (int)Math.Ceiling(_scrollViewer.ViewportHeight \/ itemHeight);<br \/>\n            _lazyCtx.PageSize &#061; (int)Math.Ceiling(oneScreen * preload);<br \/>\n        }<br \/>\n        #endregion<\/p>\n<p>        #region \u52a0\u8f7d\u4e0b\u4e00\u9875\u6570\u636e<br \/>\n        private void LoadNextPage()<br \/>\n        {<br \/>\n            if (_lazyCtx.IsLoading) return;<br \/>\n            IList source &#061; AllItems;<br \/>\n            var visible &#061; VisibleItems;<br \/>\n            if (source &#061;&#061; null || visible &#061;&#061; null || _lazyCtx.LoadedItemIndex &gt;&#061; source.Count)<br \/>\n                return;<\/p>\n<p>            _lazyCtx.IsLoading &#061; true;<br \/>\n            try<br \/>\n            {<br \/>\n                int take &#061; Math.Min(_lazyCtx.PageSize, source.Count &#8211; _lazyCtx.LoadedItemIndex);<br \/>\n                for (int i &#061; 0; i &lt; take; i&#043;&#043;)<br \/>\n                {<br \/>\n                    visible.Add(source[_lazyCtx.LoadedItemIndex &#043; i]);<br \/>\n                }<br \/>\n                _lazyCtx.LoadedItemIndex &#043;&#061; take;<br \/>\n            }<br \/>\n            finally<br \/>\n            {<br \/>\n                _lazyCtx.IsLoading &#061; false;<br \/>\n            }<br \/>\n        }<br \/>\n        #endregion<\/p>\n<p>        #region \u6eda\u52a8\u9884\u52a0\u8f7d\u903b\u8f91<br \/>\n        private void ScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e)<br \/>\n        {<br \/>\n            if (_lazyCtx &#061;&#061; null || _lazyCtx.IsLoading) return;<br \/>\n            CalcPageSize();<\/p>\n<p>            IList source &#061; AllItems;<br \/>\n            if (source &#061;&#061; null || _lazyCtx.LoadedItemIndex &gt;&#061; source.Count) return;<\/p>\n<p>            double itemHeight &#061; _lazyCtx.MeasuredItemHeight &gt; 0 ? _lazyCtx.MeasuredItemHeight : 30;<br \/>\n            double remain &#061; _scrollViewer.ExtentHeight &#8211; (_scrollViewer.VerticalOffset &#043; _scrollViewer.ViewportHeight);<br \/>\n            \/\/ \u8ddd\u79bb\u5e95\u90e8\u5c0f\u4e8e\u534a\u884c\u9ad8\u5ea6&#xff0c;\u89e6\u53d1\u9884\u52a0\u8f7d<br \/>\n            if (remain &lt; itemHeight * 0.5)<br \/>\n            {<br \/>\n                LoadNextPage();<br \/>\n            }<br \/>\n        }<br \/>\n        #endregion<\/p>\n<p>        #region \u5bf9\u5916\u516c\u5f00\u91cd\u7f6e\u65b9\u6cd5<br \/>\n        public void Reset()<br \/>\n        {<br \/>\n            if (_lazyCtx &#061;&#061; null || VisibleItems &#061;&#061; null) return;<br \/>\n            IList source &#061; AllItems;<br \/>\n            if (source &#061;&#061; null) return;<\/p>\n<p>            VisibleItems.Clear();<br \/>\n            _lazyCtx.LoadedItemIndex &#061; 0;<br \/>\n            _lazyCtx.IsLoading &#061; false;<br \/>\n            LoadNextPage();<br \/>\n        }<br \/>\n        #endregion<br \/>\n    }<br \/>\n}<\/p>\n<h3>\u4e03\u3001XAML \u4f7f\u7528\u793a\u4f8b<\/h3>\n<h4>7.1 LazyDataGrid \u8868\u683c\u7528\u6cd5<\/h4>\n<p>&lt;local:LazyDataGrid AutoGenerateColumns&#061;&#034;False&#034;<br \/>\n                   IsEnabled&#061;&#034;True&#034;<br \/>\n                   PreloadScreen&#061;&#034;1.2&#034;<br \/>\n                   AllItems&#061;&#034;{Binding Items}&#034;&gt;<br \/>\n    &lt;local:LazyDataGrid.Columns&gt;<br \/>\n        &lt;DataGridTextColumn Header&#061;&#034;\u7f16\u53f7&#034; Binding&#061;&#034;{Binding Id}&#034;\/&gt;<br \/>\n        &lt;DataGridTextColumn Header&#061;&#034;\u6570\u636e\u540d\u79f0&#034; Binding&#061;&#034;{Binding Name}&#034;\/&gt;<br \/>\n    &lt;\/local:LazyDataGrid.Columns&gt;<br \/>\n&lt;\/local:LazyDataGrid&gt;<\/p>\n<h4>7.2 LazyListBox \u5217\u8868\u7528\u6cd5<\/h4>\n<p>&lt;local:LazyListBox IsEnabled&#061;&#034;True&#034;<br \/>\n                   PreloadScreen&#061;&#034;1.2&#034;<br \/>\n                   AllItems&#061;&#034;{Binding Items}&#034;&gt;<br \/>\n    &lt;local:LazyListBox.ItemTemplate&gt;<br \/>\n        &lt;DataTemplate&gt;<br \/>\n            &lt;TextBlock Text&#061;&#034;{Binding Name}&#034; Margin&#061;&#034;6,4&#034; FontSize&#061;&#034;14&#034;\/&gt;<br \/>\n        &lt;\/DataTemplate&gt;<br \/>\n    &lt;\/local:LazyListBox.ItemTemplate&gt;<br \/>\n&lt;\/local:LazyListBox&gt;<\/p>\n<h3>\u516b\u3001\u7a97\u53e3\u6d4b\u8bd5\u540e\u53f0\u4ee3\u7801<\/h3>\n<p>using System;<br \/>\nusing System.Collections.Generic;<br \/>\nusing System.Collections.ObjectModel;<br \/>\nusing System.Windows;<\/p>\n<p>namespace WpfAttachedLazyLoad<br \/>\n{<br \/>\n    public partial class MainWindow : Window<br \/>\n    {<br \/>\n        public LazyListViewModel Vm { get; set; } &#061; new LazyListViewModel();<\/p>\n<p>        public MainWindow()<br \/>\n        {<br \/>\n            InitializeComponent();<br \/>\n            DataContext &#061; Vm;<br \/>\n            \/\/ \u521d\u59cb\u5316\u5341\u4e07\u6761\u6d4b\u8bd5\u5927\u6570\u636e<br \/>\n            LoadFirstBigData();<br \/>\n        }<\/p>\n<p>        \/\/\/ &lt;summary&gt;<br \/>\n        \/\/\/ \u9996\u6b21\u52a0\u8f7d\u5341\u4e07\u6761\u6d4b\u8bd5\u6570\u636e<br \/>\n        \/\/\/ &lt;\/summary&gt;<br \/>\n        private void LoadFirstBigData()<br \/>\n        {<br \/>\n            var list &#061; new List&lt;ItemModel&gt;();<br \/>\n            for (int i &#061; 1; i &lt;&#061; 100000; i&#043;&#043;)<br \/>\n            {<br \/>\n                list.Add(new ItemModel { Id &#061; i, Name &#061; $&#034;\u6d4b\u8bd5\u6570\u636e_{i}&#034; });<br \/>\n            }<br \/>\n            Vm.Items &#061; new ObservableCollection&lt;ItemModel&gt;(list);<br \/>\n        }<\/p>\n<p>        \/\/\/ &lt;summary&gt;<br \/>\n        \/\/\/ \u52a8\u6001\u5237\u65b0\u66ff\u6362\u6570\u636e\u6e90&#xff08;\u63a7\u4ef6\u81ea\u52a8\u91cd\u7f6e&#xff0c;\u65e0\u9700\u624b\u52a8\u7f16\u7801&#xff09;<br \/>\n        \/\/\/ &lt;\/summary&gt;<br \/>\n        private void Btn_Refresh_Click(object sender, RoutedEventArgs e)<br \/>\n        {<br \/>\n            var newList &#061; new List&lt;ItemModel&gt;();<br \/>\n            for (int i &#061; 2000; i &lt;&#061; 80000; i&#043;&#043;)<br \/>\n            {<br \/>\n                newList.Add(new ItemModel { Id &#061; i, Name &#061; $&#034;\u5237\u65b0\u540e\u6570\u636e_{i}&#034; });<br \/>\n            }<br \/>\n            Vm.Items &#061; new ObservableCollection&lt;ItemModel&gt;(newList);<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<h3>\u4e5d\u3001\u5173\u952e\u6280\u672f\u603b\u7ed3 &amp; \u907f\u5751\u6e05\u5355<\/h3>\n<h4>1. \u5f7b\u5e95\u653e\u5f03\u9644\u52a0\u5c5e\u6027\u7684\u539f\u56e0<\/h4>\n<p>\u9644\u52a0\u5c5e\u6027\u7ed1\u5b9a\u5728\u66ff\u6362\u6570\u636e\u6e90\u96c6\u5408\u573a\u666f\u4e0b\u5b58\u5728\u539f\u751f\u901a\u77e5\u4e22\u5931\u95ee\u9898&#xff0c;\u5c5e\u4e8eWPF\u5e95\u5c42\u56fa\u6709\u7f3a\u9677&#xff0c;\u65e0\u6cd5\u901a\u8fc7\u4e1a\u52a1\u4ee3\u7801\u4fee\u590d&#xff0c;\u4f1a\u5bfc\u81f4\u4e8c\u6b21\u5237\u65b0\u754c\u9762\u65e0\u54cd\u5e94\u3002<\/p>\n<h4>2. \u5f7b\u5e95\u653e\u5f03Behavior\u7684\u539f\u56e0<\/h4>\n<p>Behavior\u5c5e\u4e8eFreezable\u975eUI\u5bf9\u8c61&#xff0c;\u4e0d\u5728\u53ef\u89c6\u5316\u6811\u4e2d&#xff0c;\u4f9d\u8d56\u5c5e\u6027\u7684\u66f4\u65b0\u673a\u5236\u4e0e\u539f\u751f\u63a7\u4ef6\u4e0d\u4e00\u81f4&#xff0c;\u6570\u636e\u6e90\u4e8c\u6b21\u66ff\u6362\u5fc5\u7136\u5237\u65b0\u5931\u6548&#xff0c;\u7a33\u5b9a\u6027\u65e0\u6cd5\u4fdd\u969c\u3002<\/p>\n<h4>3. \u81ea\u5b9a\u4e49\u7ee7\u627f\u63a7\u4ef6\u65b9\u6848\u7684\u6838\u5fc3\u4f18\u52bf<\/h4>\n<p>\u76f4\u63a5\u7ee7\u627f\u539f\u751fDataGrid\u3001ListBox\u5b9e\u73b0\u7684\u81ea\u5b9a\u4e49\u63a7\u4ef6&#xff0c;\u5b8c\u5168\u9075\u5faaWPF\u6807\u51c6\u7ed1\u5b9a\u673a\u5236&#xff0c;\u5c5e\u6027\u53d8\u66f4\u3001\u6570\u636e\u6e90\u66ff\u6362\u3001\u591a\u8f6e\u5237\u65b0\u5747\u7a33\u5b9a\u89e6\u53d1\u56de\u8c03&#xff0c;\u5f7b\u5e95\u6839\u6cbb\u7ed1\u5b9a\u5931\u6548\u95ee\u9898\u3002<\/p>\n<h4>4. \u63a7\u4ef6\u80fd\u529b\u8fb9\u754c\u8bf4\u660e<\/h4>\n<p>\u5f53\u524d\u7248\u672c\u4e3a\u5355\u5411\u5411\u4e0b\u61d2\u52a0\u8f7d&#xff08;\u6eda\u52a8\u5230\u5e95\u90e8\u7eed\u9875&#xff09;&#xff0c;\u53ef\u6ee1\u8db390%\u4ee5\u4e0a\u684c\u9762\u4e1a\u52a1\u5927\u6570\u636e\u5217\u8868\u573a\u666f\u3002\u5982\u9700\u53cc\u5411\u865a\u62df\u6eda\u52a8&#xff08;\u4e0a\u4e0b\u6eda\u52a8\u6309\u9700\u52a0\u8f7d\u533a\u95f4\u6570\u636e&#xff09;&#xff0c;\u53ef\u57fa\u4e8e\u73b0\u6709\u67b6\u6784\u4e8c\u6b21\u6269\u5c55\u3002<\/p>\n<h3>\u5341\u3001\u7ed3\u8bed<\/h3>\n<p>\u8fd9\u5957 LazyDataGrid \/ LazyListBox \u662f\u7ecf\u8fc7\u591a\u8f6e\u8e29\u5751\u3001\u67b6\u6784\u8fed\u4ee3\u540e\u7684\u5de5\u4e1a\u7ea7\u7a33\u5b9a\u65b9\u6848&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5f7b\u5e95\u89e3\u51b3 WPF \u5927\u6570\u636e\u5217\u8868\u6e32\u67d3\u5361\u987f\u3001UI\u5361\u6b7b\u95ee\u9898<\/p>\n<\/li>\n<li>\n<p>\u5f7b\u5e95\u89e3\u51b3\u884c\u4e1a\u901a\u7528\u7684\u63a7\u4ef6\u4e8c\u6b21\u5237\u65b0\u4e0d\u66f4\u65b0\u7684\u7ed1\u5b9a\u7384\u5b66\u95ee\u9898<\/p>\n<\/li>\n<li>\n<p>\u7eaf\u89c6\u56fe\u5c42\u4f18\u5316&#xff0c;\u96f6\u4fb5\u5165ViewModel&#xff0c;\u8d34\u5408MVVM\u67b6\u6784<\/p>\n<\/li>\n<li>\n<p>\u65e0\u7b2c\u4e09\u65b9\u4f9d\u8d56\u3001\u65e0\u5185\u5b58\u6cc4\u6f0f&#xff0c;\u53ef\u76f4\u63a5\u590d\u7528\u81f3\u6240\u6709WPF\u9879\u76ee<\/p>\n<\/li>\n<\/ul>\n<p>\u540e\u7eed\u9879\u76ee\u4e2d\u6240\u6709\u5927\u6570\u636e\u8868\u683c\u3001\u5927\u6570\u636e\u5217\u8868\u573a\u666f&#xff0c;\u53ef\u7edf\u4e00\u66ff\u6362\u4e3a\u672c\u5957\u61d2\u52a0\u8f7d\u63a7\u4ef6&#xff0c;\u5b9e\u73b0\u9879\u76ee\u5168\u5c40UI\u6027\u80fd\u6807\u51c6\u5316\u4f18\u5316\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u524d\u8a00&#xff1a;WPF \u5927\u6570\u636e\u5217\u8868\u7684\u901a\u7528\u75db\u70b9\u5728 WPF \u9879\u76ee\u4e2d&#xff0c;\u76f4\u63a5\u7ed9 DataGrid \/ ListBox \u7ed1\u5b9a\u51e0\u4e07\u3001\u5341\u51e0\u4e07\u6761\u6570\u636e&#xff0c;\u4f1a\u51fa\u73b0\u4e25\u91cd\u95ee\u9898&#xff1a;UI \u5361\u6b7b\u3001\u9996\u6b21\u6e32\u67d3\u6781\u6162\u63a7\u4ef6\u521d\u59cb\u5316\u963b\u585e\u3001\u7a97\u53e3\u5361\u987f\u539f\u751f\u865a\u62df\u5316\u5728\u590d\u6742\u6a21\u677f\u3001\u5206\u7ec4\u3001\u5217\u81ea\u9002\u5e94\u573a\u666f\u4e0b\u5931\u6548\u4e1a\u52a1\u5c42\u9700\u8981\u5168\u91cf\u52a0\u8f7d\u6570\u636e&#xff0c;\u65e0\u6cd5\u505a\u5230\u6eda\u52a8\u6309\u9700\u6e32\u67d3\u884c\u4e1a\u5e38\u89c4\u65b9\u6848&#xff1a;\u524d\u7aef\u5206\u9875 \/ \u540e\u7aef\u5206\u9875&#xff0c;\u4f46\u5f88\u591a\u684c\u9762\u7aef\u4e1a\u52a1\u9700\u8981\u5168\u91cf\u62ff\u5230\u5185\u5b58\u3001\u524d\u7aef\u6eda\u52a8\u61d2\u52a0\u8f7d\u3002\u4e3a\u6b64&amp;#xf<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1862],"topic":[],"class_list":["post-108154","post","type-post","status-publish","format-standard","hentry","category-server","tag-wpf"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>WPF \u9ad8\u6027\u80fd\u61d2\u52a0\u8f7d\u63a7\u4ef6 LazyDataGrid \/ LazyListBox \u5b9e\u73b0\u4e0e\u8e29\u5751\u5168\u590d\u76d8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/108154.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WPF \u9ad8\u6027\u80fd\u61d2\u52a0\u8f7d\u63a7\u4ef6 LazyDataGrid \/ LazyListBox \u5b9e\u73b0\u4e0e\u8e29\u5751\u5168\u590d\u76d8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001\u524d\u8a00&#xff1a;WPF \u5927\u6570\u636e\u5217\u8868\u7684\u901a\u7528\u75db\u70b9\u5728 WPF \u9879\u76ee\u4e2d&#xff0c;\u76f4\u63a5\u7ed9 DataGrid \/ ListBox \u7ed1\u5b9a\u51e0\u4e07\u3001\u5341\u51e0\u4e07\u6761\u6570\u636e&#xff0c;\u4f1a\u51fa\u73b0\u4e25\u91cd\u95ee\u9898&#xff1a;UI \u5361\u6b7b\u3001\u9996\u6b21\u6e32\u67d3\u6781\u6162\u63a7\u4ef6\u521d\u59cb\u5316\u963b\u585e\u3001\u7a97\u53e3\u5361\u987f\u539f\u751f\u865a\u62df\u5316\u5728\u590d\u6742\u6a21\u677f\u3001\u5206\u7ec4\u3001\u5217\u81ea\u9002\u5e94\u573a\u666f\u4e0b\u5931\u6548\u4e1a\u52a1\u5c42\u9700\u8981\u5168\u91cf\u52a0\u8f7d\u6570\u636e&#xff0c;\u65e0\u6cd5\u505a\u5230\u6eda\u52a8\u6309\u9700\u6e32\u67d3\u884c\u4e1a\u5e38\u89c4\u65b9\u6848&#xff1a;\u524d\u7aef\u5206\u9875 \/ \u540e\u7aef\u5206\u9875&#xff0c;\u4f46\u5f88\u591a\u684c\u9762\u7aef\u4e1a\u52a1\u9700\u8981\u5168\u91cf\u62ff\u5230\u5185\u5b58\u3001\u524d\u7aef\u6eda\u52a8\u61d2\u52a0\u8f7d\u3002\u4e3a\u6b64&amp;#xf\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/108154.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-20T17:13:27+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/108154.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/108154.html\",\"name\":\"WPF \u9ad8\u6027\u80fd\u61d2\u52a0\u8f7d\u63a7\u4ef6 LazyDataGrid \/ LazyListBox \u5b9e\u73b0\u4e0e\u8e29\u5751\u5168\u590d\u76d8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-20T17:13:27+00:00\",\"dateModified\":\"2026-09-20T17:13:27+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/108154.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/108154.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/108154.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WPF \u9ad8\u6027\u80fd\u61d2\u52a0\u8f7d\u63a7\u4ef6 LazyDataGrid \/ LazyListBox \u5b9e\u73b0\u4e0e\u8e29\u5751\u5168\u590d\u76d8\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WPF \u9ad8\u6027\u80fd\u61d2\u52a0\u8f7d\u63a7\u4ef6 LazyDataGrid \/ LazyListBox \u5b9e\u73b0\u4e0e\u8e29\u5751\u5168\u590d\u76d8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/108154.html","og_locale":"zh_CN","og_type":"article","og_title":"WPF \u9ad8\u6027\u80fd\u61d2\u52a0\u8f7d\u63a7\u4ef6 LazyDataGrid \/ LazyListBox \u5b9e\u73b0\u4e0e\u8e29\u5751\u5168\u590d\u76d8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001\u524d\u8a00&#xff1a;WPF \u5927\u6570\u636e\u5217\u8868\u7684\u901a\u7528\u75db\u70b9\u5728 WPF \u9879\u76ee\u4e2d&#xff0c;\u76f4\u63a5\u7ed9 DataGrid \/ ListBox \u7ed1\u5b9a\u51e0\u4e07\u3001\u5341\u51e0\u4e07\u6761\u6570\u636e&#xff0c;\u4f1a\u51fa\u73b0\u4e25\u91cd\u95ee\u9898&#xff1a;UI \u5361\u6b7b\u3001\u9996\u6b21\u6e32\u67d3\u6781\u6162\u63a7\u4ef6\u521d\u59cb\u5316\u963b\u585e\u3001\u7a97\u53e3\u5361\u987f\u539f\u751f\u865a\u62df\u5316\u5728\u590d\u6742\u6a21\u677f\u3001\u5206\u7ec4\u3001\u5217\u81ea\u9002\u5e94\u573a\u666f\u4e0b\u5931\u6548\u4e1a\u52a1\u5c42\u9700\u8981\u5168\u91cf\u52a0\u8f7d\u6570\u636e&#xff0c;\u65e0\u6cd5\u505a\u5230\u6eda\u52a8\u6309\u9700\u6e32\u67d3\u884c\u4e1a\u5e38\u89c4\u65b9\u6848&#xff1a;\u524d\u7aef\u5206\u9875 \/ \u540e\u7aef\u5206\u9875&#xff0c;\u4f46\u5f88\u591a\u684c\u9762\u7aef\u4e1a\u52a1\u9700\u8981\u5168\u91cf\u62ff\u5230\u5185\u5b58\u3001\u524d\u7aef\u6eda\u52a8\u61d2\u52a0\u8f7d\u3002\u4e3a\u6b64&amp;#xf","og_url":"https:\/\/www.wsisp.com\/helps\/108154.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-20T17:13:27+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"10 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/108154.html","url":"https:\/\/www.wsisp.com\/helps\/108154.html","name":"WPF \u9ad8\u6027\u80fd\u61d2\u52a0\u8f7d\u63a7\u4ef6 LazyDataGrid \/ LazyListBox \u5b9e\u73b0\u4e0e\u8e29\u5751\u5168\u590d\u76d8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-20T17:13:27+00:00","dateModified":"2026-09-20T17:13:27+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/108154.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/108154.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/108154.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"WPF \u9ad8\u6027\u80fd\u61d2\u52a0\u8f7d\u63a7\u4ef6 LazyDataGrid \/ LazyListBox \u5b9e\u73b0\u4e0e\u8e29\u5751\u5168\u590d\u76d8"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/108154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=108154"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/108154\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=108154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=108154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=108154"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=108154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}