Is there a way to determine if a row is visible?
Scenario:After adding a new row to a XamGrid with column sorting enabled, if the newly added row is visible I don't want to call ScrollCellIntoView()
Calling ScrollCellIntoView() when the row is visible scrolls the row to the top of the grid viewer - I would like for it to stay where it is
Thanks!
Hello,
I am very glad that you have solved you issue. Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
Thank you Krasimir for your help!I do apologize for the delay...
I tried your example, the cell.Control was not null and ScrollCellIntoView() was not being called, yet the new row was scrolling to the top of the grid viewer
Seems setting the new row.cell active was scrolling it to the topFollowing your lead, I've resolved the issue with:
Dispatcher.BeginInvoke(() => cell.IsActive =
true);
I am just checking if you require any further assistance on the matter.
After further research and consulting with my team I have found better approach for implementing the functionality that you are looking for. You can change the event handler for the RowAdded event to look as follows:
private void xamGrid1_RowAdded(object sender, Infragistics.Controls.Grids.RowEventArgs e) { Dispatcher.BeginInvoke(new Action(() => { if (e.Row.Cells[0].Control == null) { xamGrid1.ScrollCellIntoView(e.Row.Cells[1]); } })); }
If you need any further assistance please do not hesitate to ask.
I have created a sample application for you that demonstrates an approach for calculating if the newly added row is visible. In order to determine if the row is visible I get the VerticalScrollBar of the grid and depending on its Value property I get the index of the first row in view. Then using the ActualWidth property of the ScrollBar I calculate the count of the rows that are currently in view. Using this two values ( total rows in view and the index of the first visible row ) it is possible to check whether the currently added row will be in view.
Please let me know if this is what are you looking for or I have misunderstood your scenario.