Q:

Data binding between two textboxes in different windows using WPF

There are a number of similar queries on the internet from which I have written the following code. But it does not seem to be working.
There are two windows: Mainwindow and Window1.

Mainwindow has a textbox named RUNTIME
Window1 has a textbox STOPTIME. 

When a button on mainwindow is pressed window1 opens.
I want to create a binding between the two text boxes such that if I write something in RUNTIME and open window 1, stop time should have the same value. And when I open window1 and write something in STOPTIME it should immediately be reflected in RUNTIME.
Please note that on the main window there is no enter button. Just as anything is written in textbox RUNTIME, it is saved in a variable Time.
Main Window
     <Window> 
    .
    .
    .           
        <TextBox x:Name="RUNTIME"  Width="120" Text="{Binding runtime,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" /> 

<MenuItem Header="Menu"> 
<MenuItem Header="SubMenu" Click="set_config_param" StaysOpenOnClick="True"/> 
</MenuItem>                      
    .
    .
    .             
        </Window>

Window1
     <Window>   
.
.
.                  
    <TextBox x:Name="STOPTIME" HorizontalAlignment="Left" Height="23" Margin="145,27,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" Text="{Binding runtime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
.
.
.                   
    </Window>

The Time variable is used to store runtime/stoptime. I have created a separate class for this.
public class Time : INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;

        private string _runtime;

        private void OnPropertyChanged(String property)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(property));
            }
        }

        public string runtime
        {
            get
            {
                return _runtime;
            }
            set
            {
                _runtime = value;
                OnPropertyChanged("runtime");
            }
        }  
    }

Now the C# code.
Main Window
    public partial class MainWindow : Window
        {
           Time _Time = new Time();

            public MainWindow()
            {
                InitializeComponent();
                RUNTIME.DataContext = _Time;
    }

private void set_config_param(object sender, RoutedEventArgs e)
                {

                    bool isWindowOpen=false;
foreach (Window w in Application.current.Windows)

{
if (w is Window1)
{
isWindowOpen = true;
w.Activate();
}
if (!isWindowOpen)
{
Window1 newwindow = new Window();
newwindow.Show();
}
}}
    }

Window1
   public partial class Window1 : Window
        {
            Time _Time = new Time();

            public Window1()
            {
                InitializeComponent();

               STOPTIME.DataContext = _Time;
            }

            private void OK_Window1_Button_Click(object sender, RoutedEventArgs e)
            {

                _Time.runtime = STOPTIME.Text;
            }

}

The problem I have understood so far is that I have failed to instantiate the same instance of time in both the forms. How can I do that? Where exactly should i change my code.

A:

Copying a comment from @ jayars:
in your MainWindow, you are creating a new instance of _Time. Next in Window1, you're creating a new instance of _Time again. Try modifying public Window1() to public Window1(Time _Time), and inject the same instance via Window1 newwindow = new Window1(this._Time)

