Search code examples
wpfwpfdatagrid

WPF datagrid detecting whether the last row is visited or not?


I have a WPF Datagrid in my application and as there are more that 25000 rows should be loaded I have created a custom pagination working with shortcut keys.

Now I am wondering if there is any way to detect whether the last row of current page is visited so I can load next page and append it to my Datagrid without any shortcut keys or click?

Update: I have added an event to vertical scrollbar for datagrid, and still can't find a way to determine whether the last row has brought to view or not?

Any suggestions?


Solution

  • OK, I found the trick:

    following event helped me out:

    > void dgScrollbar_ScrollChanged(object sender, ScrollChangedEventArgs
    > e)
    >         {
    >             if (((System.Windows.Controls.ScrollViewer)(sender)).ContentVerticalOffset
    > + e.ViewportHeight == e.ExtentHeight)
    >             {
    >                 LoadNextPageBinding_Executed(null, null);
    >             }
    >         }