I'm trying to get button eventclick with reflexion. I would like to get "Btn_AddTest_Click" string for assign it to a CommandBinding. For example:
XAML
<Button x:Name="Btn_Add"
Click="Btn_AddTest_Click"/>
Behind
public async void Btn_AddTest_Click(object sender, RoutedEventArgs e)
{...}
And function:
Type ObjType = Btn_Add.GetType();
PropertyInfo eventsProperty = ObjType.GetProperty("Events", BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
EventHandlerList events = (EventHandlerList)eventsProperty.GetValue(Btn_Add, null);
But "eventsProperty" return Null, i tried with "Events", "EventClick", Click"... same return.
I got inspired by this post