I want to draw some rectangles into an outer one. Coordinates (X, Y, Width, Height) and some more parameters like background colors are given by a View Model.
The result should look like
I tried AbsoluteLayout and CollectionView (see this post). However, this does not work because AbsoluteLayout.LayoutBounds has no effect except on direct chidren of the AbsoluteLayout.
I would populate the screen in Code Behind but perhaps there is a more elegant way using Model View ViewModel and DataBinding?

Yes, AbsoluteLayout.LayoutBounds has no effect if used it in DataTemplate of CollectionView. So I am not going to use an AbsoluteLayout any more. I am gonna use StackLayout with Margin. (I know your UI could be far more complex than what I've done and I just want to share my idea here).
Here is my xaml,
In my example, I bind the Margin, Height, Width of each rectangle to ViewModel. And for ViewModel:
I don't know if it is elegant enough or not, but it is the only way i can think of using MVVM for your case. By the way, go through the collection and add each control one by one in C# is also a good way.
Hope it works for you.