Who handled my event

70 Views Asked by At

I have registered to a LostFocus event on a TextBox and yet the event is not catch - my guess is that someone else handled it. I've tried using snoop but it only shows me the MouseDown and MouseUp events (and I need the LostFocus). Any ideas on how can I find out?

Thanks

Update: Not so clear but the code where I register is:

eventInfo.AddEventHandler(cloningObject, eventDelegate);

1

There are 1 best solutions below

1
Steve On

In the XAML, make sure you assign a name to your TextBox:

<TextBox Name="MyTextBox" />

Create a function in your code behind to handle the event:

public void MyLostFocusHandler(object sender, RoutedEventArgs e) {
    // ...
}

And then in your window's constructor (assuming this is in a window):

MyTextBox.LostFocus += MyLostFocusHandler;

Note also there is another event, LostKeyboardFocus.