Nasty code alert...
menu.AddHandler(RadMenuItem.ClickEvent, new RoutedEventHandler(OnMenuItemClick));
private static void OnMenuItemClick(object sender, RoutedEventArgs e)
{
RadMenuItem menu = e.OriginalSource as RadMenuItem;
...
Do you think this works?
nonono.
RadMenuItem menu = ((RadRoutedEventArgs)e).OriginalSource as RadMenuItem;
works :S Someone didnt get the message about inheritance :S
and guess if this would work:
menu.AddHandler(RadMenuItem.ClickEvent, new RadRoutedEventHandler(OnMenuItemClick));
That would make it typesafe... but nonono, they have this check:
internal bool IsLegalHandler(Delegate handler)
{
Type type = handler.GetType();
if (type != this.HandlerType)
{
return (type == typeof(RoutedEventHandler));
}
return true;
}
Good thing with reflector, because the error message when actually trying to do this says absolutely nothing.
menu.AddHandler(RadMenuItem.ClickEvent, new RoutedEventHandler(OnMenuItemClick));
private static void OnMenuItemClick(object sender, RoutedEventArgs e)
{
RadMenuItem menu = e.OriginalSource as RadMenuItem;
...
Do you think this works?
nonono.
RadMenuItem menu = ((RadRoutedEventArgs)e).OriginalSource as RadMenuItem;
works :S Someone didnt get the message about inheritance :S
and guess if this would work:
menu.AddHandler(RadMenuItem.ClickEvent, new RadRoutedEventHandler(OnMenuItemClick));
That would make it typesafe... but nonono, they have this check:
internal bool IsLegalHandler(Delegate handler)
{
Type type = handler.GetType();
if (type != this.HandlerType)
{
return (type == typeof(RoutedEventHandler));
}
return true;
}
Good thing with reflector, because the error message when actually trying to do this says absolutely nothing.