gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 17:43:04 24 4
gpt4 key购买 nike

我正在使用 Xamarin Studio 6.1,最近升级它以使用 Xamarin Forms 项目。我似乎无法使用 OnPlatform 标签。我正在尝试这样的事情

<Grid Padding="12">
<Grid.HeightRequest>
<OnPlatform />
</Grid.HeightRequest>
</Grid>

预览器立即中断并提示 Invalid XAML: Type OnPlatform not found in xmlns="http://xamarin.com/schemas/2014/forms"

我以前从未见过此错误,也无法在线找到任何帮助。有什么想法吗?

最佳答案

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

关于c# - OnPlatform 标签在 Xamarin Forms 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39577662/

24 4 0