最新版本的Xamarin.Forms Button.CornerRadius错误

时间:2018-07-01 02:42:22

标签: c# android ios xaml xamarin

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

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上也存在错误

1 个答案:

答案 0 :(得分:0)

尝试一下:

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