使用 WPF 虚拟化 DataGrid,我需要使用“全选”方法。迭代网格本身不起作用,因为它只会选择在 UI 中可见的记录 - 但当然,如果它们是使用鼠标选择的,它们会被保留。我猜 DataTable 中的某些东西必须改变,但是什么?如果是这样,是否可以对其进行操作,以便在 DataGrid 中选择所有记录?
谢谢
=========================添加========================= ==
Eran - 感谢您的回复,但有工作将其连接起来
创建数据网格
Dim DGV As New CustomControl.DGVx With DGV .Name = "Invoice_AdHoc_DGV" .AutoGenerateColumns = False .SelectionMode = SelectionMode.Multiple End With RegisterControl(Invoice_AdHoc_Grid, DGV) RightGrid.Children.Add(DGV)
绑定到数据表
DGV.ItemsSource = AdHocDT.DefaultView
根据您的答案创建课程
Public Class ObjectSelectAll Implements System.ComponentModel.INotifyPropertyChanged Public Property Name() As String Private vIsSelected As Boolean Public Property IsSelected() As Boolean Get Return vIsSelected End Get Set(value As Boolean) vIsSelected = value RaiseEvent PropertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs("IsSelected")) End Set End Property Public Event PropertyChanged(sender As Object, e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
结束类