Monday 8 January 2018

Xamarin.Forms Custom Switch Button

 Hello Xamarians,
I am here with a new blog on Switch button. As you all know what is switch button and how it works. For example in general terms we have switch button for fan and it is used to mak fan tun on and off. Similary, in Xamarin form we have switch button to trun on and off the feature.


In Android, Ios and WPF  switch button is a UI widget to enable and disable some operations.
Switch button is also knows as flip flop.

In xamarin form we can customize the behavior of  switch button. Along with this we can also rendered the Android and IOS Properties of switch button.

Let's start with the implementation:


we will first create a class whose name is "CustomSwitch" and then we will write a code in "C #"

Now we can set properties in android project which is generated from PCL Project, also set properties in Ios Project.

Please make sure and add view reference.. 
xmlns:local="clr-namespace:CustomSwitchApp"then write xaml code in main page.

Now we are using custom switch control in PCL Project..
TADDAAAA!

You should have your CustomSwitch working!!
If You want to watch related video click Here Custom Rendered Switch



Publi Property of Switch Button controls
  1. IsToggeled Boolean=(IsToggeled="True")
Features of CustomSwitch controls
  1. Custom Switch On Color Property=(SwitchOnColor="Red")
  2. Custom Switch Off Color Property=(SwitchOffColor="Yellow")
  3. Custom Switch Thumb Color Property=(SwitchThumbColor="Yellow")
  4. Custom Thumb Image Property=(SwitchThumbImage="Black")


1 comment:

  1. Can you share the custom switch renderer for android

    ReplyDelete

Featured Post

Sliding Entry In Xamarin.Forms

  Today, I am going to show you how to create a Custom Slide entry in Xamarin.Forms with animation and also using gradient color. here is Y...