Passing data between WPF forms

There are two methods that you can use. The first of which would be using ShowDialog and a public method then testing that the DialogResult is true then reading the value from the method.

i.e.

if (newWindow.ShowDialog() == true)
            this.Title = newWindow.myText();

The second method would be to create a CustomEvent and subscribe to it in the creating window like this.

MainWindow.xaml.cs

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        Window1 newWindow = new Window1();
        newWindow.RaiseCustomEvent += new EventHandler<CustomEventArgs>(newWindow_RaiseCustomEvent);
        newWindow.Show();

    }

    void newWindow_RaiseCustomEvent(object sender, CustomEventArgs e)
    {
        this.Title = e.Message;
    }
}

Window1.xaml.cs

public partial class Window1 : Window
{
    public event EventHandler<CustomEventArgs> RaiseCustomEvent;

    public Window1()
    {
        InitializeComponent();
    }
    public string myText()
    {
        return textBox1.Text;
    }
    private void button1_Click(object sender, RoutedEventArgs e)
    {

        RaiseCustomEvent(this, new CustomEventArgs(textBox1.Text));
    }
}
public class CustomEventArgs : EventArgs
{
    public CustomEventArgs(string s)
    {
        msg = s;
    }
    private string msg;
    public string Message
    {
        get { return msg; }
    }
}

In your form1 define a public property.

public string MyTextData { get; set; }

In your form2 on button click, get the instance of the form1 and set it property to the TextBox value.

var frm1 = Application.Current.Windows["form1"] as Form1;
if(frm1 ! = null)
    frm1.MyTextData  = yourTextBox.Text;

In your Form1 you will get the text in your property MyTextData

Its better if you following the convention for naming the windows. Use Window instead of Form for naming your windows in WPF. Form is usually used with WinForm applications.