我正在使用Xamarin Studio 6.1,最近将其升级为与Xamarin Forms项目一起使用。我似乎无法使OnPlatform标签正常工作。我正在尝试这样的事情
<Grid Padding="12">
<Grid.HeightRequest>
<OnPlatform />
</Grid.HeightRequest>
</Grid>
预览器会立即中断并抱怨无效的XAML:键入OnPlatform not found in xmlns="http://xamarin.com/schemas/2014/forms"
我之前从未见过这个错误,也无法在线找到任何帮助。有什么想法吗?
答案 0 :(得分:11)
可能是因为没有指定TypeArguments
。试试这个:
<Grid.HeightRequest>
<OnPlatform x:TypeArguments="x:Double"
iOS="15" Android="10" WinPhone="10"/>
</Grid.HeightRequest>
<强>更新强>
不推荐使用上述语法。新表格是:
<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>