Wpf DataGrid 启用虚拟化容器回收后 数据绑定问题

Wpf DataGrid 启用虚拟化容器回收后,DataGridRow.IsSelected 属性无法通过双向绑定将值同步到绑定的 ViewModel 上.

所以在为 DataGrid  启用虚拟化时,尽量不要启用容器回收

 

不要这样:
VirtualizingPanel.VirtualizationMode="Recycling"  
EnableRowVirtualization="True" 
EnableColumnVirtualization="True" 
VirtualizingPanel.IsContainerVirtualizable="True"
VirtualizingPanel.IsVirtualizing="True" 


要这样
VirtualizingPanel.VirtualizationMode="Standard"
EnableRowVirtualization="True"
EnableColumnVirtualization="True"
VirtualizingPanel.IsContainerVirtualizable="True"
VirtualizingPanel.IsVirtualizing="True"

 

posted @ 2022-06-30 18:03  xiejiang  阅读(91)  评论(0编辑  收藏  举报