Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Assigning a List of Children to a StackLayout

$
0
0

Assume that child1 and child2 are well formed Views. The following compiles:
var stackLayout = new StackLayout { Children = { child1, child2 } };

But the following does not compile, saying I am not allowed to assign to a read-only property:
var childrenList = new List<View> { child1, child2};
var stackLayout = new StackLayout { Children = childrenList };

Is this intentional? I don't really see that there should be any difference here. Thanks!


Viewing all articles
Browse latest Browse all 58056

Trending Articles