Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Communication between parent and child window in wpf

Tags:

c#

binding

I have a parent window which launches a child window, after doing some selection/operation in the child window is closed and I want to send some info back to the parent window (a custom class object), what's the best way to accomplish this in WPF using the features provided by WPF?

like image 633
sam Avatar asked Sep 20 '10 07:09

sam


1 Answers

You have many options:

  • You could use a custom event in your child window that the parent window listens to
  • You could define a delegate in the child window that references a method in the parent window
  • You could change the constructor for the child window to take a reference to the parent window and call a method on the parent window using that reference
  • You could possibly use the VisualTreeHelper class to get the parent window and call a method on that reference
like image 169
Rune Grimstad Avatar answered Sep 30 '22 08:09

Rune Grimstad