<Frame> Xamarin.Forms上特定于平台的CornerRadius

env*_*yM6 6 xaml xamarin xamarin.forms

我正在尝试分配不同的CornerRadius内容iOSAndroid例如:

<Frame
    HasShadow="false"
    Padding="10"
    BackgroundColor="Red">
    <Frame.CornerRadius>
        <OnPlatform x:TypeArguments="x:Double">
            <On
                Platform="iOS">20</On>
            <On
                Platform="Android">30</On>
        </OnPlatform>
    </Frame.CornerRadius>
    <Label
        Text="Hello World" />
</Frame>
Run Code Online (Sandbox Code Playgroud)

但是得到一个

无法分配属性“ CornerRadius”:属性不存在或不可分配,或者值和属性之间的类型不匹配

我试过x:TypeArguments="Thickness"x:TypeArguments="x:Int32"。反汇编程序集似乎CornerRadius是类型float。但是,中没有Float属性x namespace,我的意思x:TypeArguments="x:Float"是不存在。

有任何想法我做错了还是这是一个错误?

Sus*_*ver 11

CornerRadius类型是Single

<Frame HasShadow="true" OutlineColor="Red">
    <Frame.CornerRadius>
        <OnPlatform x:TypeArguments="x:Single">
            <On Platform="iOS" Value="20"/>
            <On Platform="Android" Value="30"/>
        </OnPlatform>
    </Frame.CornerRadius>
    <Frame.Content>
        <Label Text="Welcome to Xamarin Forms!" VerticalOptions="Center" HorizontalOptions="Center" />
    </Frame.Content>
</Frame>
Run Code Online (Sandbox Code Playgroud)

  • 在 Xamarin.Forms 4.5+ 上,x:TypeArguments 属性应设置为“Int32” (3认同)