Receive wpf-child-usercontrol-events in winForm-parent
Hello,
I have a winForm application that host a WPF user control. For that I am using the ElementHost-class to add the WPF-Control into my winForm. The wpf control has the dock style fill, so that it covers the whole client area of the winForm. The problem is that my winForm application doesn't receive any mouse/keyboard events anymore. How can I tell the wpfControl to route all events to its parent container???
Thanks in advance....
Re: Receive wpf-child-usercontrol-events in winForm-parent
Quote:
Originally Posted by
kakalake
Hello,
I have a winForm application that host a WPF user control. For that I am using the ElementHost-class to add the WPF-Control into my winForm. The wpf control has the dock style fill, so that it covers the whole client area of the winForm. The problem is that my winForm application doesn't receive any mouse/keyboard events anymore. How can I tell the wpfControl to route all events to its parent container???
Thanks in advance....
The same would happen when you cover your full winform with a simple usercontrol. All the events will go to that usercontrol no one to the form, because the top surface is covered from that usercotrol. Create delegates for all the events you need ( for example if your wpf control wears a textbox and you need the text chane event then fire a text change event... what ever. But as much as I know there is no such a method which simple relais all your events to the form. ) There is maybe one chance for the key events Have you already tried to switch the forms KeyPreview Property to true. This way the key strokes should be catched from the form before they are directed to their destination control on your usercontrol.
But instead of trying to get the events to the form IMHO think about modern design patterns like MVC pattern,which should solve all your problems.
Havin a datalayer and a Cotrol class that controls the dataflow and the states of your controls on your screen will be much better then using the forms class to do all that stuff.