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
60
How to determine the count of visible records.
posted

I am trying to add paging to the XamDataGrid and am having trouble determining the number of datarows that are visible to determine page size.

It seems like this should be easy but I am messing something up. The best I can come up with is to get the ActualHeight-HeaderHeight-VertScrollHeight/CellHeight. That seems more complicated than it should be.

If someone has a better method, I would welcome it.

Thanks in advance.

  • 28925
    Suggested Answer
    Offline posted

    Hello Otis,

    The quickest way to get a count of the visible rows would be to utilize the datagrid's GetRecordsInView. It's a collection you can perform a count on. The method will also ask for you to pass in true or false as a parameter to determine whether or not you want to include any child/descendent records as part of the count that are currently not expanded.

    private void window_Loaded(object sender, RoutedEventArgs e)
            {
               object[] visibleRowCollection = xamDataGrid.GetRecordsInView(false);
               
               visibleRowCollection .Count();

            }

    Let me know if you have any questions.