none
Adding new event handler to custom control does not fire event.

    Question

  • CustomControl cc = new CustomControl();

    cc.MouseDoubleClick += new MouseButtonEventHandler(CustomControl_DoubleClick);

    private void CustomControl_DoubleClick(object sender, MouseButtonEventArgs args)

    {

    MessageBox.Show("Event Fired!");

    }

     

    Can anyone tell me why this wouldn't work? Is there something I have to do in my custom control to get this event to fire?

     

    Monday, October 09, 2006 4:17 PM

Answers

  • After digging further I found that the DragCanvas I was using was overriding the OnPreviewMouseLeftButtonDown event and had 'e.handled = true' so that no other mouse events would fire. Oh well, thanks anyways to those who responded.
    Monday, October 09, 2006 7:49 PM

All replies

  • Is the control being added to the visual tree? I don't see this happening in your code.
    Monday, October 09, 2006 4:33 PM
  • Yes, It is being added to a canvas. The Canvas is a custom one that allows dragging any UIElements within it.

    this.TaskCanvas.Children.Add(CustomControl);

    Monday, October 09, 2006 4:39 PM
  • After digging further I found that the DragCanvas I was using was overriding the OnPreviewMouseLeftButtonDown event and had 'e.handled = true' so that no other mouse events would fire. Oh well, thanks anyways to those who responded.
    Monday, October 09, 2006 7:49 PM