0

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);

shahar eldad
  • 861
  • 1
  • 12
  • 31

1 Answers1

0

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.

Steve
  • 6,334
  • 4
  • 39
  • 67
  • I suppose this doesn't necessarily answer your question of why your event isn't firing, but I've never seen an event registered like you're doing. – Steve Jun 19 '13 at 15:40