When calculating its height, the Grid element stops when it reaches a hidden row. This is demonstrated by the attached program.
The program creates a grid with 3 rectangles. The middle rectangle is hidden.
The white background's height is set to be 50 pixels larger than the grid's height. When the middle rectangle is hidden, the grid's height can be see to be only the height of the first rectangle (the white background can be seen to cover only half of the 3rd rectangle). By clicking on the window, it is possible to hide and unhide the middle rectangle. When the middle rectangle is visible, the white rectangle is seen to be 50 pixels after the third rectangle, which is what is expected