title: Textbox created in WPF is not editable at run time
body: <p>I am creating a WPF Window in which I have text boxes. However, when I run the project in Debug mode, (F5), I am not able to edit the text boxes that I created, nor am I able to choose from the listbox that I created. I googled, found that WPF and Win32 need to communicate to accept keyboard input, and got these 3 lines : </p>
  
  <pre><code>Window w = new Window1();
  System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(w);
  w.Show();
  </code></pre>
  
  <p>However, I am new to C# and hence I have absolutely no idea where to insert this C# code. I added the System.Windows.Forms and WindowsFormIntegration references to my project.</p>
  
  <p>The window I am designing will be the first window that will appear at the launch of the application, hence I need the textboxes in this window to be editable without launching another window. Kindly guide me.</p>
  
  <p>Edit : This is my XAML code:</p>
  
  <pre><code>&lt;Window x:Name="Window1" x:Class="Myproject.MainWindow"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Risk Assessment"
  Height="741" Width="1216.091"&gt;
  
  &lt;GroupBox x:Name="GroupBox1"&gt;
      &lt;Grid&gt;
          &lt;TextBox x:Name="Length"  IsReadOnly ="False" IsEnabled="True" /&gt;
      &lt;/Grid&gt;
  &lt;/GroupBox&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>This is my C# code:</p>
  
  <pre><code>namespace Myproject
  {
     public partial class MainWindow : Window
     {   
         public MainWindow()
         {
             InitializeComponent();        
         }
     }
  }
  </code></pre>
  
  <p>Edit 2: I modified the first line in the App.Xaml code like this : </p>
  
  <pre><code>&lt;Application x:Class="Myproject.App"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           Startup="Application_Startup"&gt;
  </code></pre>
  
  <p>And in the App.Xaml.cs I added this snippet:</p>
  
  <pre><code>private void Application_Startup(object sender, StartupEventArgs e)
      {
          MainWindow win = new MainWindow();
          ElementHost.EnableModelessKeyboardInterop(win);
          win.Show();
          System.Windows.Threading.Dispatcher.Run();
      }
  </code></pre>
  
  <p>But still no luck. Where am I going wrong?</p>