Below is the constructor and an event handler in my window.
public MyWindow() {
InitializeComponent();
foreach (RoutedEvent routedEvent in EventManager.GetRoutedEvents())
{
EventManager.RegisterClassHandler(typeof(TestUnbuggerWindow), routedEvent, OnRoutedEvent, true);
}
}
public void OnRoutedEvent(Object sender, RoutedEventArgs args)
{
}
I’m trying to preview all events, as I’m learning WPF and I think this might expose some of what is going on unseen. Anyway, I get the following build error:
Error 1 The best overloaded method match for 'System.Windows.EventManager.RegisterClassHandler(System.Type, System.Windows.RoutedEvent, System.Delegate, bool)' has some invalid arguments
Error 2 Argument 3: cannot convert from 'method group' to 'System.Delegate'
I got the loop to register for all events from this website.
I believe the problem is caused by the method signature not matching something, but I’m unsure. Could someone shed light on this for me?
you need to use the handler explicity
It is because you the compiler needs to know what type of handler you want and since the signature takes a
Delegatetype it cannot infer that you wantRoutedEventHandler.