Tech Off Thread

2 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

UserControl event handling

Back to Forum: Tech Off
  • User profile image

    I have a usercontrol and a mainwindow for some reason only the mouse events are  being captured. nothing happens when I hook the keydown event.


    public partial class myControl :


    this.KeyDown += delegate{"key pressed");};

    this.PreviewKeyDown += delegate{"key pressed");};

    // the following is captured

    this.MouseLeftButtonDown += delegate{"clicked")'};



    // the xaml for mainwindow

    <Window <insert namespaces>

    <grid name="grid1">

    <i:myControl  x:Name ="myControl1" />



    Tunneling events are raised from the mainWindow and tunnel downwards to the souce. If I register a previewkeydown event, it should get raised in the mainwindow and then tunnel to the source i.e. the usercontrol.



  • User profile image

    Apparently the events get supressed if the control does not implement them even though it has the implementation i.e. grid does not raise KeyDown event but a textbox raises it.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.