title: How to access WPF MainWindow Controls from my own .cs file
body: <p>I am a NOVICE and am very much struggling with what seems should be a very simple task.  How do I modify a property of a <code>MainWindow</code> <code>TextBlock</code>, from another cs file.  An exact code solution would be extremely helpful.</p>
  
  <p>Below is the stripped down code. Is my use of static class causing me extra issues? </p>
  
  <p>In File: MainWindow.xaml</p>
  
  <pre><code>&lt;Window x:Class="TestApp1.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="MainWindow" Height="350" Width="525"&gt;
      &lt;Grid&gt;
          &lt;TextBlock x:Name="TextBlock1" HorizontalAlignment="Left" Margin="107,71,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top"/&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>In File: MainWindow.xaml.cs  </p>
  
  <pre><code>namespace TestApp1  
  {  
  public partial class MainWindow : Window  
      {  
          public MainWindow()  
          {  
              InitializeComponent();  
              TextBlock1.Text = "Setting Text from MainWindow";  
              MyProgram.myProgramStart();  
          }  
      }  
  }  
  </code></pre>
  
  <p>In File: CodeFile1.cs</p>
  
  <pre><code>namespace TestApp1
  {
      public static class MyProgram
      {
          public static void myProgramStart()
          {
              // ... blah blah blah
  
              // I want to do something like follows, but won't compile
              MainWindow.TextBlock1.Text = "Setting Text from My Program";
          }
      }
  }  
  </code></pre>