I have a window that is hosting a user control. I wish to pass (raise) events in the parent window that should reach the user control. How do I define events in the parent window that the child user control can also receive.
As I recall the steps should be:
Lets say in your window Loaded event attach the usercontrol to the event, eg -
this.MyEvent += new this.MyDelegate(this.UserControl1.SomeMethod);
Take note that SomeMethod must match the MyDelegate definition.
For examples of how to define delegates/events then google is your friend ;) Also don't forget to unregister your usercontrol from the event, when it's no longer required (when the window closes).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.