title: Creating a custom control in Xamarin
body: <p>I'm porting my app from Windows Phone 8 to Android - and I need to create a few custom UI controls. I tried to create an XML layout, creating a LinearLayout inside it as the control and then add it dynamically (After user's desire) - but that didn't work. How can I accomplish this the easiest way as possible?</p>
  
  <p>This is the code i tried:</p>
  
  <p>MainActivity.cs:</p>
  
  <pre><code>using System;
  using Android.App;
  using Android.Content;
  using Android.Runtime;
  using Android.Views;
  using Android.Widget;
  using Android.OS;
  
  namespace Knowledge_Organizer
  {
  [Activity (Label = "Knowledge_Organizer", MainLauncher = true)]
  public class MainActivity : Activity
  {
  
      protected override void OnCreate (Bundle bundle)
      {
          base.OnCreate (bundle);
  
          // Set our view from the "main" layout resource
          SetContentView (Resource.Layout.Main);
  
          // Import the items from resources
          LinearLayout layout = FindViewById&lt;LinearLayout&gt; (Resource.Id.rootLayout);
  
          // Add the tile
          Resource.Layout.Tile tileRoot = FindViewById&lt;LinearLayout&gt; (Resource.Layout.Tile);
          var tile = (Resource.Id.projectTile);
          layout.AddView (tile);
      }
  }
  }
  </code></pre>
  
  <p>Main layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:minWidth="25px"
  android:minHeight="25px"
  android:id="@+id/rootLayout" /&gt;
  </code></pre>
  
  <p>Tile:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"&gt;
  &lt;LinearLayout
      android:orientation="horizontal"
      android:minWidth="25px"
      android:minHeight="25px"
      android:layout_width="290dp"
      android:layout_height="120dp"
      android:id="@+id/linearLayout1"
      android:background="#ff2e4653"&gt;
      &lt;TextView
          android:text="Project"
          android:textAppearance="?android:attr/textAppearanceMedium"
          android:id="@+id/projectTile"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_marginRight="0.0dp" /&gt;
  &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Thanks a lot in advance!</p>
  
  <p>Kind Regards,
  Erik</p>