I have xaml template for my MainWindow class:
...
<Button x:Name="button1" Content="Button" Click="button1_Click" />
<Label x:Name="superLabel" Content="Super content!" />
...
I wanna access superLabel field through relfections, after button click, like this:
public void button1_Click(object sender, RoutedEventArgs e)
{
Type t = typeof(MainWindow);
FieldInfo test1 = t.GetField("superLabel"); // test1 == null
FieldInfo test2 = t.GetRuntimeField("superLabel"); // test2 == null
...
}
but I am getting null in every test...
Aucun commentaire:
Enregistrer un commentaire