Tuesday, 12 December 2017

Xamarin.Forms Custom Button

Hello Friends,
Today, in this post we are taking about button and how we can use it in xamarin project. Also I can demonstrate how to access and overwrite the behavior of button from Android and Ios in PCL project. Button is a simple element which binds two different pieces of code. Similarly in Ios and Android button binds UI with the code with that we are able to perform some action on button click etc.


In Xamarin we have limitation in button UI design. So with the help pf Rendered we can we can use the native properties of button from IOS and Android into PCL project and customize the view of button as per the user requirement.

Let's start with the Implementation...


So, we will first create a class whose name is "CustomButtons" and then we will write a code in C#. we can write some code in android project to set the Border Color, Width, Radius and Background Color etc. Then we create Ios project also.


Please make sure to add view reference xmlns:local="clr-namespace:CustomButtonApp" and write Xaml code in main page.
TADDAAAA!



You should have your CustomButton working!!


If you are lazzy download here here 

If you want to watch video Click Here 

Features of CustomButton controls:-
  1. Custom Border Color Property=(CustomBorderColor="#24C4FF")
  2. Custom Background Color Property=(CustomBackgroundColor="#24C4FF")
  3. Custom Border Radius Property=(CustomBorderRadius="4")
  4. Custom Border Width Property=(CustomBorderWidth="4")
Note:
In the New Version Of  Xamarin Studio or Visual Studio(4.7.10.38) Don't Need to Customize this properties, this Property is working well in new Version(4.7.10.38).

Public Property Button controls......
  1. BorderColor    Color. =(BorderColor="AliceBlue")
  2. BorderRadius    Int32. =(BorderRadius="5")
  3. BorderWidth    Double. =(BorderWidth="4")
  4. CornerRadius    Int32. =(CornerRadius="5")
  5. Font    Font. =(Font="13")
  6. FontAttributes    FontAttributes. =(FontAttributes="Bold")
  7. FontFamily    String. =(FontFamily="")
  8. FontSize    Double. =(FontSize="Default")
  9. Image    FileImageSource. =(Image="icon")
  10. Text    String. =(Text="Submit")
  11. TextColor    Color. =(TextColor="Aqua")       

3 comments:

  1. Hi!
    Many thanks for this post. Very usefull!
    One question: How you would implement a animation at clicked event?
    Like normal button?
    Regards Michael

    ReplyDelete
  2. Hello i found your post really interesting. The only problem is when i run the app in live player, the xamarin live player stop running suddenly. ¿Can you help me?

    Thank you!

    ReplyDelete
  3. It’s my first visit to this blog, it seems that you are fond of writing since so long because the selection of topics is no nice also the information which you have mentioned here is real and impressive. Really appreciate.

    Hire Xamarin app Developers

    Xamarin Developer India

    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...