未找到“HeightRequest"的属性、BindableProperty 或事件,或者 Xamarin.Forms 中的值和属性错误之间的类型不匹配 [英] No property, BindableProperty, or event found for "HeightRequest", or mismatching type between value and property error in Xamarin.Forms

查看:35
本文介绍了未找到“HeightRequest"的属性、BindableProperty 或事件,或者 Xamarin.Forms 中的值和属性错误之间的类型不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不是Xamarin Forms 没有找到Sku"的属性、可绑定属性或事件,或者值和属性之间的类型不匹配

我是 Xamarin.Forms 的新手,正在尝试我的第一个 Hello World 应用.
我写了以下代码:

I am completely new to Xamarin.Forms and am trying my first Hello World app.
I wrote the following code:

<?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.

You are putting Label inside StackLayout, while the value you use like {ConstraintExpression Type=RelativeToView, Factor=0.05, Constant=0} is using for relativelayout.

这是两种不同的布局,您不能混合使用.阅读文档并检查那里的示例以了解如何使用它们.

These are two different layouts and you can't mix them. Read the document and check the examples there to learn how to use them.

如果您有任何问题,请随时问我:).

Feel free to ask me any question if you have:).

更新代码:

<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>

这篇关于未找到“HeightRequest"的属性、BindableProperty 或事件,或者 Xamarin.Forms 中的值和属性错误之间的类型不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆