When working with the DevExpress WPF GridControl, you can get an
InfiniteGridSizeException thrown if the grid is in a
container with potentially infinite height.
A consultation with Professor Google will show there are two suggested solutions - set
MaxHeight on the GridControl
to limit its height, or set the
AllowInfiniteGridSize property to true. These two suggestions are repeated endlessly
on the Developer Express support site.
There is, however, a simple third solution: Change the container of the GridControl so that it no longer has potentially infinite height.
For example, I’m hosting a GridControl within a NavBarControl and was getting the
NavBarGroup looked like this:
What I didn’t realise was that the NavBarGroup allows it’s content to have any height at all. Limiting the height of
the content to the visible area just required setting the
Once this was set, my GridControl stopped complaining and I was able to get on with building my application.
The lesson here is twofold:
Firstly, the exception really does indicate the source of the problem and direct you to the solution if you pay attention:
By default, an infinite grid height is not allowed since all grid rows will be rendered and hence the grid will work very slowly. To fix this issue, you should place the grid into a container that will give a finite height to the grid, or you should manually specify the grid’s Height or MaxHeight. Note that you can also avoid this exception by setting the GridControl.AllowInfiniteGridSize static property to True, but in that case the grid will run slowly.
Secondly, DeveloperExpress could do a better job of telling people how to solve the issue instead of just working around it.