The art of creating a good control

In the previous article I explained what makes a good control and where to find some. In this article i propose the foundations of a win-win architecture for a good Xamarin Forms control.

Anatomy of the foundation of a powerful xamarin forms control project

The old fashioned way to create a control is by using the wizard and choosing to create a xamarin forms control solution. It will add 4 projects: a netstandard library project, an ios library project, an android library project, an UWP library project, and 3 classes: a xamarin forms control and 3 native control renderers.

The new way to create a control is by creating a netstandard library project, adding the Xamarin.Forms nuget, adding the xamarin forms control class, adding 3 folders for iOS, Android and UWP platform renderers and helper classes, and modifying the csproj to activate the multi targeting feature natively supported by visual studio UI. Let's see how all of this can be done.

Create a netstandard project

Again, you will need Visual Studio 2019 with the latests updates. There is a community (free) version which is full featured. Please let go away Visual Studio 2017 and beyond. You won't be able to use this method on these old versions.

Steps:

I will detail only the last step, as the previous ones are straightforwards.

What is a multi targeting project ?

When you build a normal project, it compiles the source files and dependencies into assemblies, all put into a target folder, in the hidden "Debug" subfolder when the Debug config is selected, or "Release" subfolder when the Release config is selected.