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
close icon

LISTVIEW LeftSwipeTemplate & MVVM

Hi,
Do you have a sample project that shows how to use SFListView swipetemplate with MVVM. The SFListView must have 2 entry controls in the datatemplate (entry1 & entry2) and 2 button controls in the leftswipetemplate (button1 & button2). Each button needs to fire a command in the ViewModel. When button1 on a specific row is clicked, it needs to reset values of entry1 & entry2 to "UNKNOWN" (for that specific row) as well as update the itemsource data. I will also like to see a sample where at the click on a button on the page, all rows for entry1 and entry2 will be set to "UNKNOWN" (something like a reset all button) as well as update the itemsource data. 

I have gone through the documentation and forums and seen different examples that have one or more features described above but have not been able to tie everything together to get what I want. Is this even do-able using MVVM?

Thanks in advance!

9 Replies

DB Dinesh Babu Yadav Syncfusion Team April 22, 2019 11:01 AM UTC

Hi Bamame,  
  
Thanks for using Syncfusion products.  
  
We have checked your requirement from our end. We have prepared the sample based on the information given by you and changed the entry value of the swiped item. We have attached the sample for your reference and you can download it from the below link.  
  
  
Please let us know if you require further assistance on this.  
  
Regards,  
Dinesh Babu Yadav.  




BA Bamame April 24, 2019 11:30 PM UTC

This is really helpful. Thanks a lot!


DB Dinesh Babu Yadav Syncfusion Team April 25, 2019 04:33 AM UTC

Hi Bamame, 
 
Thanks for the update. Please let us know if you require further assistance. 
 
Regards, 
Dinesh Babu Yadav 



JO Jordan August 15, 2019 07:10 PM UTC

Hi there,

Is it possible to use a button in the swipe template? I've tried and the app crashes. Stack Trace attached:

Image works but button crashes the app.

I;ve tried to paste the template code here but it won;'t allow

Thanks in advance


JO Jordan August 15, 2019 07:10 PM UTC

Stack trace

Attachment: listview_button_swipe_ce867131.zip


JO Jordan August 15, 2019 07:11 PM UTC

<listview:SfListView.LeftSwipeTemplate>
                        <DataTemplate x:Name="offlineJobLeftSwipeTemplate">
                            <Grid HorizontalOptions="Center" VerticalOptions="Center">
                                
                                <Image BackgroundColor="Transparent" HeightRequest="35" Source="delete.png" WidthRequest="35">
                                    <Image.GestureRecognizers>
                                        <TapGestureRecognizer Command="{Binding BindingContext.RemoveJobCommand, Source={x:Reference Name=offlineJobsListViewSf} }" CommandParameter="{Binding}" />
                                    </Image.GestureRecognizers>
                                </Image>

                                <!--<Button Text="&#xf2ed;"
                                    TextColor="White"
                                    FontSize="32"
                                    Padding="0"
                                    HorizontalOptions="CenterAndExpand"
                                    VerticalOptions="CenterAndExpand"
                                    BackgroundColor="Transparent"
                                    Command="{Binding BindingContext.RemoveJobCommand, Source={x:Reference Name=offlineJobsListViewSf} }"
                                    CommandParameter="{Binding .}"
                                    FontFamily="{StaticResource FontAwesomeRegular}" />-->

                            </Grid>
                        </DataTemplate>
                    </listview:SfListView.LeftSwipeTemplate>


SR Sangeetha Raju Syncfusion Team August 19, 2019 12:04 PM UTC

Hi Jordan, 
 
We have checked the reported query “Crash occurs when using button in SwipeTemplate” from our side. We would like to let you know that we didn’t face any crash as reported while using button with command. We have attached the tested sample for your reference. Please download the sample from the below link. 
 
 
Could you please check with the above sample and please revert us with reproducible/modified sample which will be helpful for us to analyze the issue cause and provide appropriate solution at our end. 
 
Please let us know if you have any concern. 
 
Regards,
Sangeetha Raju.
 



SM Steven Marcus July 16, 2020 07:19 PM UTC

Sorry to bring up an old thread but wanted to thank the Syncfusion team for the sample MVVM code

http://www.syncfusion.com/downloads/support/forum/144131/ze/Swiping1487684542

It was super helpful!!!! Love it.!


LN Lakshmi Natarajan Syncfusion Team July 17, 2020 04:51 AM UTC

Hi Steven, 
 
We are very glad to have your valuable feedback and appreciation :). Please get back to us if you need any other assistance. As always we will be happy to assist you.  
  
Regards, 
Lakshmi Natarajan 
 


Loader.
Live Chat Icon For mobile
Up arrow icon