1
提起我的XAML模板我的MainWindow类:无法访问XAML的模板,通过字段信息
...
<Button x:Name="button1" Content="Button" Click="button1_Click" />
<Label x:Name="superLabel" Content="Super content!" />
...
我想通过访问relfections superLabel领域,点击按钮后,像这样:
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
...
}
但我在每次测试得到空 ...
它的作品!谢谢@Roma –
@DariuszFilipiak,不客气 –