views:

241

answers:

0

I am converting a WPF application to a similar WPF User Control. And the user control is hosted on WinForm using ElementHost.

public partial class UserControl1:UserControl  // public partial class Window1 : Window
{
    private void UserControl_Loaded(object sender, RoutedEventArgs e) // Window_Loaded(object sender, RoutedEventArgs e)
    {
     this.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(UserControl1_PreviewMouseLeftButtonDown);
    }

    void UserControl1_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
     if(e.Source.GetType() == typeof(MyFoo)) 
            // this comes out to be FALSE everytime coz 
            // e.Source.GetType() is UserControl.UserControl1.
            // NOTE: In WPF Application e.Source.GetType() gives MyFoo.
     { 

     }
    }
}

public class MyFoo:Foo
{

}

How should I resolve this issue?
EDIT:
I have tried adding the events to MyFoo object but it detects that MyFoo is clicked and does the job but it is creating other problems.