title: Cannot access class from another class c#
body: <p>I'm trying to access public partial class ChooseExercises : Window from public partial class YourProgress : Window, but it throws an exception:</p>
  
  <pre><code>System.InvalidCastException: 'Unable to cast object of type 'GymCheckList.YourProgress' to type 'GymCheckList.ChooseExercises'.'
  </code></pre>
  
  <p>The way I'm trying to access it is:</p>
  
  <pre><code>namespace GymCheckList
  {
      /// &lt;summary&gt;
      /// Interaction logic for YourProgress.xaml
      /// &lt;/summary&gt;
      public partial class YourProgress : Window
      {
          public YourProgress()
          {
              InitializeComponent();
          }
  
  private void TabThursday_Loaded(object sender, RoutedEventArgs e)
  {
      ChooseExercises ce = (ChooseExercises)Application.Current.MainWindow;
      var lol = ce;
  }
  </code></pre>
  
  <p>If I use ChooseExerises ce = new ChooseExercises(); it gives me empty ce incstance. What may cause the exception?
  Thanks!</p>
  
  <p>Edit</p>
  
  <p>In ChooseExeprises class I used similar code to access the MainWindow class and it works fine:</p>
  
  <pre><code>namespace GymCheckList
  {
      /// &lt;summary&gt;
      /// Interaction logic for ChooseExercises.xaml
      /// &lt;/summary&gt;
      public partial class ChooseExercises : Window
      {
          public ChooseExercises()
          {
              InitializeComponent();
          }
          private List&lt;string&gt; data = new List&lt;string&gt;();
          public void ComboBox_Loaded(object sender, RoutedEventArgs e)
          {
              MainWindow kek = (MainWindow)Application.Current.MainWindow;
  </code></pre>