Exactly what we as seasoned XAML developers would expect.
Converted to Xamarin Forms XAML this turns into:
Only difference is the property name to set the background color. However, if we look at this at runtime we see a completely different story.
It looks like the inner Grid isn’t rendered at all. But let’s try to add a Label to the inner Grid.
So what exactly is going on here? The inner Grid (the blue one) doesn’t specify any columns, that means that by default there’s only one column available. In Microsoft XAML the width of that default column is set to “*” so it takes up all available space. In Xamarin Forms that width is set to “Auto” so it only takes up the space it needs. A subtle difference with a big impact.
To fix this, add a column with “*” as width
result:
In this post I’ve shown a difference in implementation between Xamarin Forms XAML and Microsoft XAML and how to fix it.
Note that this sample is based on Xamarin Forms 1.2. Xamarin has stated that they will change the implementation in Forms 1.3 to reflect the Microsoft implementation.
This is an imported post. It was imported from my old blog using an automated tool and may contain formatting errors and/or broken images.
Leave a Comment