Created
August 13, 2021 15:46
-
-
Save SmashBrando/7821faee6eedfa916486d097bc18a813 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the control's Type | |
Type controlViewType = ((UIElement)control).GetType(); | |
// Dig out the undocumented (yes, I know, it's risky) EventHandlerStore | |
// from the control's Type | |
PropertyInfo EventHandlersStoreType = | |
controlViewType.GetProperty("EventHandlersStore", | |
BindingFlags.Instance | BindingFlags.NonPublic); | |
// Get the actual "value" of the store, not just the reflected PropertyInfo | |
Object EventHandlersStore = EventHandlersStoreType.GetValue(tree, null); | |
var miGetRoutedEventHandlers = EventHandlersStore.GetType().GetMethod("GetRoutedEventHandlers", BindingFlags.Public | BindingFlags.Instance); | |
RoutedEventHandlerInfo[] res = (RoutedEventHandlerInfo[])miGetRoutedEventHandlers.Invoke(EventHandlersStore, new object[] { CheckedTreeViewItem.CheckedEvent }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment