我正在使用Xamarin Studio 6.1,最近将其升级为与Xamarin Forms项目一起使用.我似乎无法使OnPlatform标签工作.我正在尝试这样的事情
<Grid Padding="12"> <Grid.HeightRequest> <OnPlatform /> </Grid.HeightRequest> </Grid>
预览器立即中断并抱怨无效的XAML:在xmlns =“http://xamarin.com/schemas/2014/forms”中找不到类型OnPlatform@H_301_5@
解决方法
这可能是因为没有指定TypeArguments.试试这个:
<Grid.HeightRequest> <OnPlatform x:TypeArguments="x:Double" iOS="15" Android="10" WinPhone="10"/> </Grid.HeightRequest>
更新:@H_301_5@
不推荐使用上面的语法.新表格是:@H_301_5@
<Grid.HeightRequest> <OnPlatform x:TypeArguments="x:Double"> <On Platform="iOS" Value="15"/> <On Platform="Android" Value="10"/> <On Platform="WinPhone" Value="10"/> </OnPlatform> </Grid.HeightRequest>