Hi Gilbert,
this approach works for me in version 3.1 (exactly 3.1.0.110), and for Glass layout, but I do not think that is the matter.
If you can post the code for your your layout or upload the file, I believe I will be able to found out what is wrong.
Regards.
Filip