title: Add a Child to the Parent on Button Click Xamarin.forms
body: <p>I have been trying to add a Label view to the Stacklayout on Button Click in Android.
  But It throws Null Pointer exception. Below is what I'm trying to achieve. Can anyone please advice on how to achieve this in xamarin.forms</p>
  <p><strong>Xamarin.Forms Code in C#</strong></p>
  <pre><code> StackLayout parent= new StackLayout ();
  
   Button add= new Button
          {
              HorizontalOptions=LayoutOptions.End,
              BackgroundColor=Xamarin.Forms.Color.White,
              Text=&quot;ADD&quot;,
              TextColor=Xamarin.Forms.Color.Maroon,
          };
  
   add.Clicked += OnButtonClicked;
   
   Label firstLabel = new Label
          {
              Text = &quot;Label 1&quot;,
              HorizontalOptions = LayoutOptions.StartAndExpand,
              TextColor=Xamarin.Forms.Color.FromHex(&quot;#000000&quot;)
          };
   parent.Children.Add(add);
   parent.Children.Add(firstLabel );
  </code></pre>
  <p><strong>Adding Label in ButtonClick</strong></p>
  <pre><code> void OnButtonClicked(object sender, EventArgs e)
   {
  
     Label secondLabel = new Label
          {
              Text = &quot;Label 1&quot;,
              HorizontalOptions = LayoutOptions.StartAndExpand,
              TextColor=Xamarin.Forms.Color.FromHex(&quot;#000000&quot;)
          };
    parent.Children.Add(secondLabel ); 
  }
  </code></pre>
  <p>Thanks in Advance</p>