title: Bind a WPF mainWindow TextBox to a variable calculated in a user control C#
body: <p>I have a textBox on my main Window and I have a user control with Images (Bitmaps). Through a mouse click on an Image, a value is calculated. This value should be displayed on the textBox in the main window. 
  1) without data binding
  How could I access the textBox object on the main window from the user control. It works the other way round, i.e. I can access a user control textBox from the main window using the name of the user control and the textBox to access the textBox such as usercontrol1.textBoxName.
  But it seems to me that I cannot access a main window textBox from the usercontrol such as mainWindow.textBoxName because the user control does not know the main Window and has no main Window object. Is this correct?
  2) with data binding
  It probably works with data binding. But what I tried so far did not work. In the main window XAML:  </p>
  
  <pre><code>TextBox  Text="{Binding Path=usercontrol1.GetCycleNumber()}"   Name="cycleNumberBox" 
  </code></pre>
  
  <p>in mainWindow.cs:</p>
  
  <pre><code>public partial class MainWindow : Window , INotifyPropertyChanged 
  </code></pre>
  
  <p>I added the INotifyPropertyChanged</p>
  
  <pre><code>public event PropertyChangedEventHandler PropertyChanged;
  private  void RaisePropertyChanged(string propertyName)
    {
        PropertyChangedEventHandler handler = this.PropertyChanged;
        if (handler != null)
          {
            handler(this, new PropertyChangedEventArgs(propertyName));
          }
      }
  
      public  void CycleChanged()
      {
        this.cycleNumber = usercontrol1.GetCycleNumber();
              if (this.cycleNumberBox.Text != cycleNumber)
              {
                this.cycleNumberBox.Text = cycleNumber;
                 RaisePropertyChanged("cycleNumber");
  
           }
  
    }
  </code></pre>
  
  <p>usercontrol1.cs
  Now I would have to signal a change with</p>
  
  <pre><code>RaisePropertyChanged("cycleNumber"); 
  </code></pre>
  
  <p>in the user control. However, I cannot access this method.
  Since I spent days already to figure this out, I would be glad for any help.
  I am beginner and it is my first project. Thank you!</p>