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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Sample solution for SfSwitchRenderer

Thread ID:

Created:

Updated:

Platform:

Replies:

145780 Jul 8,2019 01:18 PM UTC Jul 10,2019 12:45 PM UTC Xamarin.Forms 5
loading
Tags: SfSwitch
Codrina Merigo
Asked On July 8, 2019 01:18 PM UTC

Hello,

I have an Xamarin Forms 4 solution and I tried to use the Switchrenderer by following the guide on the website, but I didn't managed to use it, due to a missing reference( I guee code.iOS)

Is there any sample for using the switch? 

Muneesh Kumar G [Syncfusion]
Replied On July 8, 2019 01:41 PM UTC

Hi Codrina,  
 
Greetings from Syncfusion.  
 
We have analyzed your query and you can get the complete details and sample for SfSwitch in below location.  
 
 
  
Regards, 
Muneesh Kumar G. 
 


Codrina Merigo
Replied On July 9, 2019 07:09 AM UTC

Thank you, but it's there any way to use the version 17.1.0.53 and have this component?

Muneesh Kumar G [Syncfusion]
Replied On July 9, 2019 08:41 AM UTC

Hi Codrina,   
  
No. Because we have implemented SfSwitch component in 17.2.0.28 only. So, if you want to use this component, you have to update our version.  
   
Regards,  
Muneesh Kumar G.  


Codrina Merigo
Replied On July 10, 2019 10:21 AM UTC

Ok, thank you.

One more question, I have created a listview containing a switch with x:Name set to a bindable property of type String "switch" + index(SwitchName). 

 
                                                x:Name="{Binding SwitchName}"
                                                AutomationId="{Binding SwitchName}"
                                                Grid.Row="0"
                                                Grid.Column="1"
                                                AllowIndeterminateState="False"
                                                IsOn="{Binding IsActive}"
                                                StateChanged="SfSwitch_StateChanged">

Is there any way to find which Switch has been triggered, based on SwitchName, from  
private void SfSwitch_StateChanged(object sender, EventArgs e)
        {

        }

Thank you very much for your help

Muneesh Kumar G [Syncfusion]
Replied On July 10, 2019 12:45 PM UTC

Hi Codrina, 
 
Thanks for your update. 
 
We have analysed your requirement of "Finding which SfSwitch has been triggered, based on Switch name".  Accessing control name in the code behind is not possible at all when control is placed inside DataTemplate. Please find the below link for more information. 
 
 
Based on that we have prepared a custom sample using AutomationID property also we can find the current state of SfSwitch using IsOn property. 
 
Code snippet 
 
private void SfSwitch_StateChanged(object sender, EventArgs e)
        {
            string automationId = (sender as SfSwitch).AutomationId;
            DisplayAlert(automationId, "Current State : " + (sender as SfSwitch).IsOn, "Ok");
        }
 
 
 
Please find the sample from the below link and let us know if you have any other concerns.  
 
 
Regards, 
Muneesh Kumar G.   
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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
Live Chat Icon