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

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

最佳答案

尝试这个:

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

关于c# - 最新版本的Xamarin.Forms Button.CornerRadius错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51120488/

相关文章:

c# - UWP 值不能为空。参数名称 : path1

android - Markdown如何更改默认的文本大小Android Markwon

iphone - 尝试将 .plist 中的 BOOL 值存储到实现文件中的 BOOL 变量时崩溃

c# - Windows 操作系统中的 Outlook 签名文件夹

c# - 将 XLS 内容从云端同步到 iOS 或 Android 应用程序内存的最佳策略

c# - (重新)使用约束类型的泛型参数而不声明它们

android - PanoramaGL 的替代品

android - 如何在 WebView 中显示方向

ios - Parse Cocoapod 破坏本地化

ios - 在 View Controller 之间传递数据