gpt4 book ai didi

xamarin.forms - 找不到 “HeightRequest”的属性,BindableProperty或事件,或者Xamarin.Forms中的值和属性错误之间的类型不匹配

转载 作者:行者123 更新时间:2023-12-02 10:44:49 27 4
gpt4 key购买 nike

不是Xamarin Forms No property, bindable property, or event found for 'Sku', or mismatching type between value and property的副本
我对Xamarin.Forms完全陌生,正在尝试我的第一个Hello World应用程序。
我写了以下代码:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="hello_world.MainPage">
<StackLayout>
<Label
Text="Welome"
BackgroundColor="Yellow"
TextColor="Green"
HeightRequest="{ConstraintExpression Type=RelativeToView, Factor=0.05, Constant=0}"
FontSize="Medium" />
</StackLayout>

</ContentPage>
但是,我收到错误
No property, BindableProperty, or event found for "HeightRequest", or mismatching type between value and property.
我要去哪里错了?

最佳答案

您将Label放入StackLayout内,而您使用的值(例如{ConstraintExpression Type=RelativeToView, Factor=0.05, Constant=0})则用于relativelayout
这是两种不同的布局,您不能混合使用。阅读文档并查看其中的示例以了解如何使用它们。
如果您有任何问题,请随时问我:)。
更新代码:

<RelativeLayout>
<Label
Text="Welome"
BackgroundColor="Yellow"
TextColor="Green"
FontSize="Medium"

RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"

RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, Factor=0.05,Property= Height, Constant=0}"
/>
</RelativeLayout>

关于xamarin.forms - 找不到 “HeightRequest”的属性,BindableProperty或事件,或者Xamarin.Forms中的值和属性错误之间的类型不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64003252/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com