I have created a TextBox dynamically and attached a Tap event handler to it using:
control.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(OnClick1);
It works fine. But, now I want to change the event handler to point to some different method. I tried:
control.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(OnClick2);
But, it still points to first event handler. i.e. OnClick1. What can I do to make it point OnClick2? Also is there a way to remove this event handler completely?
You need to remove the first handler first:
(Note the rather simpler use of method group conversions, instead of explicitly creating the event handler. It does the same thing, but is much more readable.)