Thank you for the example. This is not quite the functionality that I need. I need to resize the entire grid, not the grid rows.
Here's a scenario:
If my maximum height is 250, and my header height is 40.
If I have 5 rows with heights 50, 60, 55, 60, and 50, my grid will be at height 250, and will require scrolling to see the last row
If I have 2 rows with heights 50 and 60, my grid will resize to height 150 to fill only the height that is required for the header and the 2 rows. Layout constraints on the grid and it's surrounding components will adjust to use the space that is no longer taken up by the grid.
Additionally, I am getting a bit of odd behavior with the grid in the example that was provided. I've seen similar issues in my app as well. In the ViewModel, if you call SetRowstoGenerate(5), when the grid is initially displayed it only shows 3 rows. If you start scrolling the grid, the remaining 2 rows appear.