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

Disable swiping past the last card [SOLVED]

Hi there,
I am using a SfCardLayout that has 1 to 10+ cards. I have it set up that the user swipes through the cards like a carousel (the cards don't dismiss). However, when the user swipes the last card, the layout is left empty and it looks odd.

See attached zip file. cards1.png looks great but when the user swipes past the last card they end up with a screen that looks like cards2.png.

How do I prevent the user from swiping past the last card? I always want there to be a card on screen.


Thanks,
Ronan

Attachment: cards_4fbe6929.zip

5 Replies

RA Rachel A Syncfusion Team October 30, 2019 06:41 AM UTC

Hi Ronan, 
  
Greetings from Syncfusion.  
  
We have achieved your requirement using the VisibleCardIndexChanging event in the SfCardLayout. Please find the sample for your reference.  
   
   
Code Snippet:  
Xaml:  
   
<cards:SfCardLayout VisibleCardIndexChanging="CardVisibleCardIndexChanging">  
   
   
C#:  
   
void CardVisibleCardIndexChanging(object sender, VisibleCardIndexChangingEventArgs e)  
{  
    e.Cancel = e.NewCard == null;  
}  
   
   
Please let us know if you need further assistance on this.  
  
Thanks,  
Rachel. 


RB Ronan Burke October 30, 2019 08:55 AM UTC

Hi Rachel,
Thank you very much, this solution works perfectly!

Thanks,
Ronan


RA Rachel A Syncfusion Team October 30, 2019 08:56 AM UTC

Hi Ronan, 
 
Thanks for the confirmation. 
 
Please let us know if you have any other queries. 
 
Thanks, 
Rachel. 



PE Pedro February 20, 2020 09:39 AM UTC

Hello

I have tested your solution in order to disable swipping and it's working:

   
void CardVisibleCardIndexChanging(object sender, VisibleCardIndexChangingEventArgs e)  
{  
    e.Cancel = true;  
}  

Is there any other way to disable swipping?

Thanks


SJ Suyamburaja Jayakumar Syncfusion Team February 21, 2020 12:50 PM UTC

Hi Pedro, 
 
Currently we don’t have another solution for disable swipping. we will update you in future once we got a better solution than previous update. 
 
Regards, 
Suyamburaja J. 


Loader.
Up arrow icon