最新版本的Xamarin.Forms Button.CornerRadius错误 [英] Error with latest version Xamarin.Forms Button.CornerRadius

查看:75
本文介绍了最新版本的Xamarin.Forms Button.CornerRadius错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[更新:代码已在Android 8.0模拟器上运行] 我一直收到错误消息,找不到类型Button的CornerRadius属性 我的代码在后面

[Update: Code worked on Android 8.0 simulator] I keep receive error No CornerRadius property found for the type Button My code behind

public TabbedPage1 ()
    {
        InitializeComponent();
        this.FindByName<Button>("runButton").CornerRadius = screenX / 5;
    }

我的xaml

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="FuckThis.TabbedPage1">
    <ContentPage x:Name="Page1">
        <RelativeLayout>
            <Button xmlns:android="http://schemas.android.com/apk/res/android"
                    x:Name="runButton"
                    Text="Run"
                    RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width,Factor=0.4}"
                    RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width,Factor=0.4}"
                    RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height,Factor=0.3}"
                    RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width,Factor=0.3}"
                    BorderRadius="200"
                    CornerRadius="200"
             />
        </RelativeLayout>
    </ContentPage>
</TabbedPage>

我已经尝试过BorderRadius,但是由于新的Xamarin.Forms 3.1版本而无法正常工作 在另一种尝试中,CornerRadius在Android上工作,并在iOS上显示错误,但是后来我尝试创建新项目,并且一切都完成了,现在在Android上也存在错误

I've tried BorderRadius but it didnt work due to new Xamarin.Forms version 3.1 In another try, CornerRadius worked on Android and showed error on iOS, but then I tried to create new project and all f...ed up, now it's bug on Android also

推荐答案

尝试一下:

public TabbedPage1 ()
{
    InitializeComponent();
    runButton.CornerRadius = screenX / 5;
}

这篇关于最新版本的Xamarin.Forms Button.CornerRadius错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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