Template random resize

Is there some document describing how to set the layout inside a template to make the resize behave as expected, both when resized in the designer and when the window size changes in the client? Never had any problems setting the layout of a component in a window, however inside a template everything seems random.

I have the ‘Enable Layout’ checkbox set to true.

The question comes from spending the last 3 hours making a template behave. The solution ended up being something totally unexpected with a obscure combination of anchored and relative layouts and containers doing nothing but adding an extra layer of layout settings.