May 22nd, 2009, 08:58 AM
Receive wpf-child-usercontrol-events in winForm-parent
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....
May 22nd, 2009, 03:15 PM
Re: Receive wpf-child-usercontrol-events in winForm-parent
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.
Originally Posted by kakalake
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.
Last edited by JonnyPoet; May 22nd, 2009 at 03:21 PM.
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!