加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – OnPlatform标签在Xamarin Forms中不起作用

发布时间:2020-12-15 08:47:09 所属栏目:百科 来源:网络整理
导读:我正在使用Xamarin Studio 6.1,最近将其升级为与Xamarin Forms项目一起使用.我似乎无法使OnPlatform标签工作.我正在尝试这样的事情 Grid Padding="12" Grid.HeightRequest OnPlatform / /Grid.HeightRequest/Grid 预览器立即中断并抱怨无效的XA??ML:在xmlns
我正在使用Xamarin Studio 6.1,最近将其升级为与Xamarin Forms项目一起使用.我似乎无法使OnPlatform标签工作.我正在尝试这样的事情
<Grid Padding="12">
    <Grid.HeightRequest>
        <OnPlatform />
    </Grid.HeightRequest>
</Grid>

预览器立即中断并抱怨无效的XA??ML:在xmlns =“http://xamarin.com/schemas/2014/forms”中找不到类型OnPlatform

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

解决方法

这可能是因为没有指定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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读