简体   繁体   中英

Xamarin.Forms UWP Button renderer CornerRadius

The BorderRadius property has been deprecated. The new CorderRadius does not exists in FormsButton in Xamarin.Forms UWP Button Renderer.

Using the the deprecated BorderRadius property causes the app to crash.

Control.BorderRadius = Element.CornerRadius; (inside OnElementPropertyChanged)

I am using Xamarin 3.0.0.446417 on VS 15.7.1

Thanks.

The BorderRadius property has been deprecated.

BorderRadius is FormsButton property where under Xamarin.Forms.Platform.UWP namespace, and it has not be deprecated. And it is an extension property base on UWP Button class for rendering corner.

CornerRadius is Button property where under Xamarin.Forms namespace. And it is cross-platform property that you could rendered in other platform.

You have no need to reset BorderRadius in the custom button render, you could use the following directly.

<Button BorderRadius="15" Text="Click"/>

Because it has been used in the ButtonRenderer .

The CornerRadius has a negative value that causes the app to crash.

protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{

    if (e.PropertyName == "CornerRadius")
    {

        if (Element.CornerRadius >= 0)
        {
            base.OnElementPropertyChanged(sender, e);
        }
    }

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM