I would like to have the gridview paging size dynamically adjusted when gridview height changed, so that the grid would not have any void, nor would user require to scroll up and down.
I handled the gridview's SizeChanged event and tried the following code:
sender, SizeChangedEventArgs e)
(e.HeightChanged && ItemsList.ActualHeight > 0)
var pageSize = (
)(ItemsList.ActualHeight / ItemsList.RowHeight);
(pageSize > 0)
ItemPager.PageSize = pageSize;
It pretty much worked, except when the column header is visible, as it the taller than the row height, the above calculation is not exact anymore. It also doesn't handle when horizontal scrollbar is visible.
Is there a better way to calculate the number of rows that should be visible?