Cannot use Controls.Add in WPF application
<p>When I write Controls.Add() to dynamically create a control in a window, it says that Controls is not defined or present in window class. In other words "Controls" is not being recognized as a class or command and hence the code is not working. Any suggestions will be appreciated.</p>

<p>I want to dynamically create a window and add a textbox to it.</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

 public partial class Window2 : Window
    {
        public Window2()
        {
             InitializeComponent();
        } 

private void button2_Click(object sender, RoutedEventArgs e)
        {
            Window f1 = new Window();
            f1.Show();
            TextBox tb = new TextBox();
            tb.Width = 150;
            tb.Height = 60;
            tb.Name = "TextBoxID";
            tb.Text = "This is textbox first data";
            Controls.Add(f1);  


        }
    }
</code></pre>
