I am using PLinqInstantFeedbackSource when populating the grid.
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();
}
So when i select all rows using:
((DevExpress.Xpf.Grid.TableView)gridControl.View).SelectAll();
it seems to select all the rows. So this is working fine, but the user has not scrolled down so that all the rows are visible or fetched.
So now i want to loop through all the rows and get the row object using:
var selectedRowHandles = ((DevExpress.Xpf.Grid.TableView)gridControl.View).GetSelectedRowHandles().AsEnumerable();
foreach (var item in selectedRowHandles)
{
SomeViewModel.SelectedItems.Add((SomeEntityObject)gridControl.GetRow(item));
}
This seems to work fine for all visible rows, but when it tries to Get the next row that is not visible it throws an exception:
InvalidCastException
Unable to cast object of type 'DevExpress.Data.NotLoadedObject' to type 'SomeEntityObject'.
So, how to get all rows in the GridControl when using PLinqInstantFeedbackSource when row is not visible.
Found the right answer from DevExpress.