Setting AutoDistributionGrid.FitCellsOfHeight to non Double.NaN value directs grid to automatically create as many columns of the height specified as the property value that can fully fit in the grid's height (but at least one). When grid height is changed, the number of rows is adjusted automatically.