We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to set shadow effect to the cards in Xamarin.Forms

Platform: Xamarin.Forms |
Control: SfCardLayout

The SfCardView is a Syncfusion UI component that helps organizing the content as cards. This section explains how to add shadow effect to cards in Xamarin.Forms. The shadow effect can be achieved by enabling the HasShadow property of CardView.

 

Also, you can customize the shadow effect color by customizing ShadowColor property in CardView.

 

Consider the use case of showing a list of social media applications in a Xamarin.Forms application as below.

 

Cardview with shadow

 

[XAML]

..
 
      <ListView   x:Name="EventListView"
                  RowHeight="100"
                  SeparatorVisibility="None"
                  ItemsSource="{Binding Items}">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <cards:SfCardView   Margin="10" HasShadow="True" ShadowColor="LightBlue">
                            <Grid HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                                <StackLayout Orientation="Horizontal" >
                                    <Image Margin="10,0,0,0" Source="{Binding Image}" 
                                                  HeightRequest="40"   WidthRequest="40"/>
                                    <Label Margin="10,0,0,0" FontAttributes="Bold"
                                           FontSize="16" MaxLines="1" Text="{Binding Title}"
                                           LineBreakMode="NoWrap" TextColor="Black"
                                           HorizontalOptions="Start" VerticalOptions="Center" />
                                </StackLayout>
                            </Grid>
                        </cards:SfCardView>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
 

 

[C#]

 

public class CardModel
{
    public string Title {get; set;}
 
    public string Image {get; set;}
}

 

 [C#]

public class CardViewModel
{
   public IEnumerable<CardModel> Items { get; set; }
 
        public CardViewModel()
        {
            Items = new CardModel[]
            {
                new CardModel(){ Title = "Facebook" , Image = "FacebookFill.png"},
                new CardModel(){ Title = "Gmail" , Image = "GmailFill.png"},
                new CardModel(){ Title = "Instagram" , Image = "InstagramFill.png"},
                new CardModel(){ Title = "WhatsApp" , Image = "WhatsAppFill.png"},
            };
        }
}

 

Note:

Shadow card support is only available in iOS and Android platforms.

 

Download the sample here

 

See Also

How to dismiss the cards programmatically

Available customization in cards

Notify events to visible index changed

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile