Reputation: 1000
What I'm trying to do may seem to be simple but I have been looking for around an hour with no luck so far.
I have the following XAML
<StackLayout Grid.Row="2" Margin="20,20,20,20">
<StackLayout.VerticalOptions>
<OnPlatform x:TypeArguments="x:String">
<On Platform="Android" Value="CenterAndExpand" />
<On Platform="iOS" Value="EndAndExpand" />
</OnPlatform>
</StackLayout.VerticalOptions>
</StackLayout>
But it's giving an error saying:
Cannot assign property VerticalOptions, property does not exists, or is not assignable, or mismatching type between value and property
I have done the same successfully but for other properties of type x:Boolean, x:Double and Thickness... Out of curiosity I've been also trying to find some documentation that outlines all the available x:TypeArguments as a reference but still with no luck as well.
Upvotes: 4
Views: 2293
Reputation: 3607
Your problem is in this line
<OnPlatform x:TypeArguments="x:String">
You are saying that the value is a String however it's a LayoutOptions
type. So changing this, it works:
<StackLayout Margin="20,20,20,20">
<StackLayout.VerticalOptions>
<OnPlatform x:TypeArguments="LayoutOptions">
<On Platform="Android" Value="CenterAndExpand" />
<On Platform="iOS" Value="EndAndExpand" />
</OnPlatform>
</StackLayout.VerticalOptions>
</StackLayout>
In the Xamarin documentation you can see that VerticalOption
is a LayoutOption
:
Syntax
public LayoutOptions VerticalOptions { get; set; }
Value
A LayoutOptions which defines how to lay out the element. Default value is LayoutOptions.Fill unless otherwise documented.
I hope this can help you.
Upvotes: 9