OnPlatform标签不适用于Xamarin Forms

Jay*_*nan 9 c# xaml cross-platform xamarin.forms

我正在使用Xamarin Studio 6.1,最近将其升级为与Xamarin Forms项目一起使用.我似乎无法使OnPlatform标签工作.我正在尝试这样的事情

<Grid Padding="12">
    <Grid.HeightRequest>
        <OnPlatform />
    </Grid.HeightRequest>
</Grid>
Run Code Online (Sandbox Code Playgroud)

预览器立即中断并抱怨无效的XA​​ML:类型 OnPlatform not found in xmlns="http://xamarin.com/schemas/2014/forms"

我以前从未见过这个错误,也无法在线找到任何帮助.有任何想法吗?

eak*_*gul 13

这可能是因为没有指定TypeArguments.试试这个:

<Grid.HeightRequest>
    <OnPlatform x:TypeArguments="x:Double"
      iOS="15" Android="10" WinPhone="10"/>
</Grid.HeightRequest>
Run Code Online (Sandbox Code Playgroud)

更新:

不推荐使用上面的语法.新表格是:

<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>
Run Code Online (Sandbox Code Playgroud)