Passing Events to children

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bluefootedpig
    New Member
    • Mar 2008
    • 7

    Passing Events to children

    This is a WPF application with C#.

    I have UserControls on a canvas. I have enabled the ability to drag and move these UserControls anywhere on the canvas. The problem comes up when these UserControls have an extender in them. For some reason, it would appear that the extender is not getting the event. So it never extends.

    I'm wondering how to fix this. Now if i set Handled to false, it will extend, but my click and dragging will lock up fairly randomly, normally within 2-3 drags.

    event is
    Code:
            protected override void OnPreviewMouseLeftButtonUp(System.Windows.Input.MouseButtonEventArgs e)
            {
    
                 
                    if (m_isDown)
                    {
                        DragFinished(false);
                        (m_originalElement as ComponentControl).
                        e.Handled = true;
                        
                    }
                   
    
             }
    DragFinish just takes a bool to know if it was cancelled or not, so this is saying on the mouseup event, to finish the drag (set the object down) and handle the event. The start code always starts on the mouse button down. It looks like...

    Code:
     protected override void OnPreviewMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e)
            {
                    if (e.Source != this)
                    {
                 
                        m_isDown = true;
                        m_startPoint = e.GetPosition(this);
                        m_originalElement = e.Source as UIElement;
    
                    }
                    e.Handled = false;
                    base.OnPreviewMouseLeftButtonDown(e);
                  
            }
    so with those two functions, if i turn either of the e.handled to true, i can't extend, if i have them the way i have it now, it locks up. So what i'm trying to figure out is how i can in this event, send a mouseUp event to the extender.

    sorry if i seemed to kind of jumble around a bit, but this problem is confusing.

    To recap:
    setting handled to false allows me to extend, but freezes when i move the object.
    setting handled to true allows me to move, but i cannot extend.
  • bluefootedpig
    New Member
    • Mar 2008
    • 7

    #2
    does anyone have an idea on how to get it so the canvas can pass the mouse event to the child?

    Comment

    Working...