How to raise Onload/OnUnload event from FrameworkElement for unit testing purposes?
As you can see here, I can't use reflection to get the multicast delegates of the private开发者_JAVA技巧 fields behind these FrameworkElement events because they aren't field-like. So how to do it?
Please try this:
yourControl.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));
It should work! :)
精彩评论