ometimes you have a table/class that have so many fields/attributes, that the mere thinking of make the interaction of the whole object give you headache. You’re not alone. For cases like this, there is a little thing called Reflections.

According to Microsoft Documentation:

Reflection provides objects (of type Type) that describe assemblies, modules and types. You can use reflection to dynamically create an instance of a type, bind the type to an existing object, or get the type from an existing object and invoke its methods or access its fields and properties. If you are using attributes in your code, reflection enables you to access them. For more information, seeExtending Metadata Using Attributes.

So, in short, you can use reflection to go through the whole class reading it attributes and properties. If you are familiar with EntityFramework, Resources and Asp.NET MVC you would get what I will be doing here.

We will be creating a Simple Xamarin.iOS & Xamarin.Mac Project with a PCL for illustrational proposes. Where we can generate the UI as dynamical as possible. The process will be divided in parts to keep things simple.

So, let’s get started

  1. Requisites
  2. Step by step


You would need Xamarin Studio or Visual Studio with Xamarin Plugin in order to follow up this guide, both can be adquired for free in their Community Editions

Step by step

  1. Open Xamarin Studio or Visual Studio
    Xamarin Studio Home
  2. Clic on New Solution from the menu on the left or clic File>New>Solution
  3. From here, choose iOS >App and choose Single View App, because we don’t require something complex for the demo.
    Screen Shot 2016-07-01 at 11.20.43 AM
  4. When you  choose that template, it will ask you to enter a name  for you project, I put GuideReflections to recognize the project later, because, you know … 🙂
  5. There will be a few wizard screens but you just clic next until you see the Done/Finish button.
  6. Once we have done that, the Solution and the iOS Project will be created and the AppDelegate class will appear.
  7. From the Left menu right clic on the solution name and choose Add > New Project, this time, from the left menu choose Multiplatform>Library>Portable Library (PCL Project) and give a name to your project I put GuideReflections.Shared to know what this project is for. In this project is where most of the magic will happen.

On the PCL Project

Here we will declare the classes that will contain the data, the model, the helpers, etc.


This post will be extended very soon

Starlin González
Latest posts by Starlin González (see all)