嗨,新的xamarin表格,
尽管使用x:name声明label元素 . 我无法在xaml文件后面的代码中使用它
<StackLayout>
<Label Text="Welcome to Xamarin.Forms!"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand"
x:Name="Heading"/>
<Button Clicked="Button_Clicked"/>
</StackLayout>
代码隐藏文件
private void Button_Clicked(object sender, EventArgs e)
{
Heading
}
严重级代码描述项目文件行抑制状态错误CS0103当前上下文中没有名称“ Headers ”App6.Android,App6.UWP C:\ Users \ Adhithya \ source \ repos \ App6 \ App6 \ App6 \ Page1.xaml .cs 22有效
2 回答
在Xaml中添加控件后,您必须构建一次 . 然后您将能够访问该控件 .
你能检查xaml文件属性Build Action应该是“Embedded resource” .