Receive wpf-child-usercontrol-events in winForm-parent
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Receive wpf-child-usercontrol-events in winForm-parent

  1. #1
    Join Date
    May 2000
    Location
    Germany
    Posts
    368

    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....

  2. #2
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,537

    Re: Receive wpf-child-usercontrol-events in winForm-parent

    Quote Originally Posted by kakalake View Post
    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.
    Last edited by JonnyPoet; May 22nd, 2009 at 03:21 PM.
    Jonny Poet

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center