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

Sample solution for SfSwitchRenderer

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? 

5 Replies

MK Muneesh Kumar G Syncfusion Team 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. 
 



CM Codrina Merigo 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?


MK Muneesh Kumar G Syncfusion Team 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.  



CM Codrina Merigo 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


MK Muneesh Kumar G Syncfusion Team 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.   
 


Loader.
Live Chat Icon For mobile
Up arrow icon