5
votes

I am trying to round the corners of a stack layout, it works on android but on iOS, they still appear square but it does display the Frame shadow

My XAML is

<ContentPage.Content>
    <StackLayout BackgroundColor="WHITE">
        <ListView>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout>
                            <Frame CornerRadius="10" Padding="0" Margin="10, 10, 10, 10">
                                <StackLayout>
                                    . . .
                                </StackLayout>
                            </Frame>
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </StackLayout>
</ContentPage.Content>
3
Any ideas? I need to find the fix to this.Dan

3 Answers

11
votes

Set IsClippedToBounds property to Frame control:

<Frame IsClippedToBounds="True" CornerRadius="10" Padding="0" Margin="10, 10, 10, 10">
    <StackLayout>
    </StackLayout>
</Frame>
4
votes

they still appear square

Actually, the Frame is round not the StackLayout, we just use Frame wrap it ,so it looks the StackLayout has round corners.

Frame

<Frame CornerRadius="10" Padding="0" Margin="10, 10, 10, 10" HasShadow="False" BackgroundColor="Red">
    <StackLayout >
         <Label Text="{Binding}"/>
    </StackLayout>
</Frame>

enter image description here

StackLayout

<Frame CornerRadius="10" Padding="0" Margin="10, 10, 10, 10" HasShadow="False" >
   <StackLayout BackgroundColor="Red">
         <Label Text="{Binding}"/>
   </StackLayout>
</Frame>

enter image description here

it does display the Frame shadow

You can disable it by HasShadow="False".

1
votes

Actually I believe, it is a bug of Xamarin.Forms. UWP, Android and iOS should behave the same, but they don't. As a result to implement the same behaviour developers need to use OnPlatform feature.

The bug is described and discussed here, it is still open: https://github.com/xamarin/Xamarin.Forms/issues/2405