我PLinqInstantFeedbackSource
在填充网格时使用。
PLinqInstantFeedbackSource pLinqInstantFeedbackDataSource = new PLinqInstantFeedbackSource();
pLinqInstantFeedbackDataSource.GetEnumerable += pLinqInstantFeedbackDataSource_GetEnumerable;
gridControl.ItemsSource = pLinqInstantFeedbackDataSource;
gridControl.DataContext = SomeViewModel;
private void pLinqInstantFeedbackDataSource_GetEnumerable(object sender, DevExpress.Data.PLinq.GetEnumerableEventArgs e)
{
e.Source = SomeViewModel.GetList();
}
因此,当我使用以下命令选择所有行时:
((DevExpress.Xpf.Grid.TableView)gridControl.View).SelectAll();
它似乎选择了所有行。所以这工作正常,但用户没有向下滚动,以便所有行都可见或获取。
所以现在我想遍历所有行并使用以下方法获取行对象:
var selectedRowHandles = ((DevExpress.Xpf.Grid.TableView)gridControl.View).GetSelectedRowHandles().AsEnumerable();
foreach (var item in selectedRowHandles)
{
SomeViewModel.SelectedItems.Add((SomeEntityObject)gridControl.GetRow(item));
}
这似乎适用于所有可见行,但是当它尝试获取不可见的下一行时会引发异常:
InvalidCastException
Unable to cast object of type 'DevExpress.Data.NotLoadedObject' to type 'SomeEntityObject'.
那么,当行不可见时,如何在使用 PLinqInstantFeedbackSource 时获取 GridControl 中的所有行。