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 reuse the dismissed cards in Xamarin.Forms SfCardView

Platform: Xamarin.Forms |
Control: SfCardLayout
Tags: cardview, cards, reuse

This section explains how to reuse a dismissed card in SfCardView. This allows reusing a single card for showing different content with every swipe. This will optimize the memory usage of your Xamarin application by avoid creating separate card for each content.

 

You can refer to this Getting Started documentation for more details about the CardView.


SfCardView supports dismissing a card from the view by enabling the SwipeToDismiss property. This property also enables reusing the dismissed card to optimize the memory usage of your Xamarin application. Please refer the below code snippet to reuse the dismissed card.

 

To add cards to your project, open the NuGet package manager in Visual Studio, search for Syncfusion.Xamarin.Cards, and then install it.

[XAML]

<StackLayout HorizontalOptions="Fill" VerticalOptions="Center">
 
            <!--  CardView with SwipeToDismiss property enabled  -->
            <cards:SfCardView
                SwipeToDismiss="True"
                Dismissed="SfCardView_Dismissed"
                HorizontalOptions="Center"
                VerticalOptions="Center">
 
                <!--  Label to show a content inside card  -->
                <Label
                    BackgroundColor="Red"
                    FontSize="Large"
                    HeightRequest="100"
                    HorizontalOptions="CenterAndExpand"
                    HorizontalTextAlignment="Center"
                    Text="Card View"
                    TextColor="White"
                    VerticalOptions="CenterAndExpand"
                    VerticalTextAlignment="Center"
                    WidthRequest="300" />
 
            </cards:SfCardView>
 
</StackLayout>

[C#]

private int cardNumber;
 
private async void SfCardView_Dismissed(System.Object sender, Syncfusion.XForms.Cards.DismissedEventArgs e)
        {
            await Task.Delay(400);
            SfCardView view = sender as SfCardView;
            (view.Content as Label).Text = "Card View " + cardNumber.ToString();
            view.IsDismissed = false;
            cardNumber++;
        }

 

Note:

SwipeToDismiss Property won’t work when you add the SfCardView as a child of SfCardLayout.

Output

CardView

 

View the sample in GitHub

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