Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
405
How to bring expansion row into view in xamgrid
posted

Hello, I have a xamgrid with expansion rows. If I expand the last row, the content of the expansion row is not visible to the user, who then has to scroll.

Is there a way to automatically bring the content into view as much as possible without losing the visibility of the original row the user has clicked on the see the expansion row?

I see the same problem in the sample application for the xamgrid.

Thanks for your help

 

Parents
No Data
Reply
  • 34830
    Suggested Answer
    Offline posted

    Hello Roberta,

    Thank you for your post.

    I have been investigating into this issue you are seeing and I was able to reproduce it on my end as well. To get around this behavior, I would recommend handling the RowExpansionChanged event of the XamGrid. This event will fire when you expand or collapse one of the parent rows and show or hide the child ones under them. To start, from the event arguments you can get the Row element that was just expanded or collapsed from the e.Row property.

    This behavior doesn't just seem to occur with the last row in the XamGrid, but also with the last visible row if that row is on the very bottom edge of the XamGrid. The XamGrid has a method named ScrollCellIntoView which can be used to achieve the requirement you are looking for, and this method takes a Cell as a parameter, which you can obtain from the Row.Cells collection. However, for this to completely work, you will need to know the number of visible rows in your grid, as well as whether the newly expanded/collapsed one is the last visible row, and whether that row actually did expand or collapse, as there is no reason to scroll further if it collapsed. You can get that last part by checking if e.Row.IsExpanded = true.

    Getting the number of visible rows in the grid is a little trickier. Each row in the grid has a CellsPanel that represents the Control property for each row. When the rows are out of view, this CellsPanel is virtualized, and so the Control property on those out of view rows will return null. I would recommend that you query your XamGrid.Rows collection to get all of the rows where row.Control != null. If e.Row is the last element in this collection, it is the last visible row in your grid currently, as long as it is on a parent band. If these conditions are true, you can get the ChildBandCollection collection from the row's ChildBands property. If there are child rows, then this ChildBandCollection will be populated with ChildBand objects. These ChildBand objects have a Rows collection of their own, which you can use to get one of the child rows' cells that you would like to scroll into view, and pass that into the XamGrid.ScrollCellIntoView method. The index of the child row that you actually scroll into view is up to you. With the default row size, I have found that the row at ChildBand.Rows[visible rows.Count - 3] places the parent row at the top of the grid while still showing the child rows.

    I have attached a sample project to demonstrate the above. I hope this helps you.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer
    Infragistics Inc.
    www.infragistics.com/support

    XamGridHierarchyScrollingCase.zip
Children
No Data