I have a Window which pop-ups another Window. I want the second Window to be able to return an object to the first Window when a button is pressed. How would I do this?
I did it like that.
In parent window make a corresponding ClosingEvent like this :
private void NewWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
NewWindow nw = (NewWindow)sender;
object Receiver = nw.Sender;
}
...and in the child window change your code implement the "sender" like this :
public partial class NewWindow : Window
{
public object Sender { get; set; }
public NewWindow()
{
InitializeComponent();
Sender = objectYouWantToSend;
}
}
So when you put data into the object "Sender" in child window, while closing this window will put the data into the "Receiver" variable.
I hope, this helps.