不是Xamarin表单的重复项。找不到“ Sku”的属性,可绑定属性或事件,或者值和属性之间的类型不匹配
我对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>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句