Filling buttons into a panel

This is somewhat related to gridTemplate but feel it deserves its own thread.

After filling a panel with 8 buttons, if I add any more buttons, I'd like all buttons to fit neatly by reducing the size of all as necessary.


You can see here after 8 buttons are added, that last button is stretched to fill the panel.

I have this in the gridTemplate property of the panel

repeat(8,50px) / auto

and am now at this point

repeat(8,50px) *now fill rest*/ auto

I have tried with auto-fill and other options but i'm going around in circles. Can anyone help me out?

repeat(9,50px) / auto

Or, use the vertical layout if you don't need multiple columns.

I guess what I was thinking was that if there are say 20 buttons to occupy this panel, a way to say that up to the first 8 should be full size (and not filling panel), and any buttons over 8 (say 12 total buttons, or 20) should be resized to fit in the panel. I thought this might work

repeat(8,50px) auto / auto

but this keeps the first 8 full size and reduces any further buttons added, which I guess is what the code means!

I wondered if I could have it that it would then automatically reduce button sizes only after 8 is reached. I guess this was the reason for the dynamic grid-template property.

Yes, this behaviour seems exactly what I am after, the first 10 buttons or so are full size, then the reduction occurs. The reason why I thought gridTemplate is a better choice was in the case of 20 buttons, then 2 columns in the panel would be better...