Custom Renderer in Shared Project

Introduction:

In this article we are going to discuss custom renderers in xamarin forms. We are going to learn about renderers and also go through example to help us develop understanding about renderers. In this article we only discuss to make renderer in xamarin forms shared project.

 

What are custom renderers?

Custom renderers in xamarin forms are used to make customizable elements according to your needs. Custom renderers gives you powerful approach to customize and handle UI elements according to your wish. You can create renderer of any element and use it according to your needs.

 

How to use?

Let’s make a custom rendere r in xamarin forms. We can make renderer both in portable project and in other projects. Let’s move towards its implementation.

 

Implementation:

 

Here we are going through example of xamarin forms .NET Standard project (Previously Portable project). We only go through example of renderer in shared project.

  • Make a xamarin forms project
  • Make a class in portable project
  • Now inherit your class with element you want to make renderer of.
  • Here I am going to make a button renderer. So, inherit class with button as shown:

 

Make a class inherit it with element you want to make renderer of. Than make a constructor and set properties according to your requirements.

 

  • Now include your button in xaml:

Let’s see how our custom button looks like.

Output:

 

So here you see our custom button which is made in xamarin forms shared project.

 

XamarinWeb Founder | MVP – C-SharpCorner | Xamarin Forms Developer

Leave a Reply

Your email address will not be published. Required fields are marked *