Xamarin Forms: StackLayout with rounded corners

后端 未结 6 1323
故里飘歌
故里飘歌 2020-12-24 10:39

I am developing an app using Xamarin Forms PCL. I need a StackLayout with rounded corners. I have tried frame as well for rounded corner container but there is no corner rad

6条回答
  •  没有蜡笔的小新
    2020-12-24 11:22

    Since Xamarin has released Effects mechanism, it now can be done by implementing a custom effect on both platforms. An advantage of this approach is that effects are more light-weight, reusable and can be parameterized and applied to any UI element.

    After you create a custom RoundCornersEffect inheriting RoutingEffect, declare a CornerRadius attached property and implement PlatformEffect on each platform, it can be applied to any Xamarin.Forms layout or control like this:

    
    

    with hardcoded corners radius or a value from resources

      
    

    Here is a link to full implementation and usage examples.

提交回复
热议问题