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:-
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
Features of CustomButton controls:-
- Custom Border Color Property=(CustomBorderColor="#24C4FF")
- Custom Background Color Property=(CustomBackgroundColor="#24C4FF")
- Custom Border Radius Property=(CustomBorderRadius="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......
Public Property Button controls......
- BorderColor Color. =(BorderColor="AliceBlue")
- BorderRadius Int32. =(BorderRadius="5")
- BorderWidth Double. =(BorderWidth="4")
- CornerRadius Int32. =(CornerRadius="5")
- Font Font. =(Font="13")
- FontAttributes FontAttributes. =(FontAttributes="Bold")
- FontFamily String. =(FontFamily="")
- FontSize Double. =(FontSize="Default")
- Image FileImageSource. =(Image="icon")
- Text String. =(Text="Submit")
- TextColor Color. =(TextColor="Aqua")
Hi!
ReplyDeleteMany thanks for this post. Very usefull!
One question: How you would implement a animation at clicked event?
Like normal button?
Regards Michael
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?
ReplyDeleteThank you!
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.
ReplyDeleteHire Xamarin app Developers
Xamarin Developer India