title: Is it possible to inflate a CustomLayout : FrameLayout in Xamarin in its own constructors and own class methods?
body: <p>Here is the example I would like to inflate... it is just a FrameLayout and I have the Layout axml file... I could inflate the layout from the parent of this FrameLayout (a Fragment)... I want this Custom FrameLayout in other fragments. In the method initialize() the compiler says  Error CS1604: Cannot assign to '' because it is read-only (CS1604) (MyProject.Mono) and then  Error CS0266: Cannot implicitly convert type 'Android.Widget.FrameLayout' to 'MyProject.Mono.ViewArtistAlbumTrack'. An explicit conversion exists (are you missing a cast?) (CS0266) (Navi.Mono)</p>
  
  <pre><code>     /// &lt;summary&gt;
       /// View artist album track.
       /// This framelayout is especific for ...
       /// &lt;/summary&gt;
         public class ViewArtistAlbumTrack : FrameLayout
  
  {
      /// &lt;summary&gt;
      /// The adapter.
      /// &lt;/summary&gt;
      public ExpandableAATitemAdapter adapter = null;
      /// &lt;summary&gt;
      /// a plain ExpandableListView
      /// &lt;/summary&gt;
      public ExpandableListView expandable = null; 
      /// &lt;summary&gt;
      /// View that triggers something sliding up
      /// &lt;/summary&gt;
      public Button albumdown = null; 
      public Button trackdown = null; 
  
      /// &lt;summary&gt;
      /// The list just AAT items. AAT is for Artist Album Track 
      /// &lt;/summary&gt;
      public List&lt;AATitem&gt; list = null; 
  
  
      public ViewArtistAlbumTrack (Context context) :
      base (context)
      {
          this.trackdown = new Button(this.Context); 
          this.albumdown = new Button(this.Context);
          this.expandable = new ExpandableListView(this.Context); 
          Initialize ();
  
  
      }
  
      public ViewArtistAlbumTrack (Context context, IAttributeSet attrs) :
      base (context, attrs)
      {
          this.trackdown = new Button(this.Context); 
          this.albumdown = new Button(this.Context);
          this.expandable = new ExpandableListView(this.Context); 
  
          Initialize ();
      }
  
      public ViewArtistAlbumTrack (Context context, IAttributeSet attrs, int defStyle) :
      base (context, attrs, defStyle)
      {
  
          Initialize ();
      }
  
  
      public void Initialize ()
      {
          try
          {
              LayoutInflater inflater =     (LayoutInflater)this.Context.GetSystemService(Context.LayoutInflaterService);
              this = (FrameLayout)inflater.Inflate(Resource.Layout.ViewAAT, null);
  
  
              Console.WriteLine("done succesfully: "+ System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString()+ "  " 
                  + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString() ); 
          }
          catch(Exception exception)
          {
              Console.WriteLine ("exception at "
                  + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString()+ "  " 
                  + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString() + " : "
                  + exception.Source.ToString() );
              Console.WriteLine ("exception at "
                  + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString()+ "  " 
                  + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString()+ " : "
                  + exception.Message.ToString() );
              Console.WriteLine ("exception at "
                  +  System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString()+ "  " 
                  + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString()+ " : "
                  + exception.StackTrace.ToString() );
              Console.WriteLine ("exception at " 
                  + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString()+ "  " 
                  + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString()+ " : "
                  + exception.TargetSite.ToString() );
          }// end of catch()
  
          //this.expandable.SetAdapter(new ExpandableAATitemAdapter(Application.Context, this.list));
      }
  
      protected override void  OnFinishInflate() 
      {
          try
          {
  
              this.trackdown = new Button(this.Context); 
  
              this.albumdown = new Button(this.Context);
  
              this.expandable = new ExpandableListView(this.Context); 
  
              this.expandable = FindViewById&lt;ExpandableListView&gt; (Resource.Id.aatexpandableid); 
              this.trackdown  = FindViewById&lt;Button&gt; (Resource.Id.aattracksbid);
              this.albumdown  = FindViewById&lt;Button&gt; (Resource.Id.aatabumsbid);
  
              this.trackdown.Visibility = ViewStates.Gone; 
              this.albumdown.Visibility = ViewStates.Gone; 
              Console.WriteLine("done succesfully: "+ System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString()+ "  " 
                  + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString() ); 
  
          }
          catch(Exception exception)
          {
              Console.WriteLine ("exception at "
                  + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString()+ "  " 
                  + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString() + " : "
                  + exception.Source.ToString() );
              Console.WriteLine ("exception at "
                  + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString()+ "  " 
                  + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString()+ " : "
                  + exception.Message.ToString() );
              Console.WriteLine ("exception at "
                  +  System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString()+ "  " 
                  + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString()+ " : "
                  + exception.StackTrace.ToString() );
              Console.WriteLine ("exception at " 
                  + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString()+ "  " 
                  + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString()+ " : "
                  + exception.TargetSite.ToString() );
          }// end of catch()
  
      }
  </code></pre>
  
  <p>}</p>