我想做的可能看起来很简单,但我已经找了大约一个小时了,到目前为止没有运气。
我有以下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>
Cannot assign property VerticalOptions, property does not exists, or is not assignable, or mismatching type between value and property
你的问题就在这一行
<OnPlatform x:TypeArguments="x:String">
LayoutOptions
<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>
在 Xamarin documentation 你可以看到 VerticalOption 是一个 LayoutOption
VerticalOption
LayoutOption
语法 价值 定义元素布局方式的布局选项。默认值为LayoutOptions。除非另有记录,否则填充。
语法
价值
定义元素布局方式的布局选项。默认值为LayoutOptions。除非另有记录,否则填充。