【发布时间】:2019-05-27 16:43:30
【问题描述】:
刚刚使用 Xamarin 做我的第一个测试应用程序。
如何(在按钮事件中)将标签中的文本从“欢迎使用 Xamarin.Forms!”更改到“Hello World”?
我尝试使用以下 XAML 脚本和 C# 代码这样做:
Stacklayout 中的 XAMLscript 和我在 mainpage.xaml.cs 中的 C# 代码:
<Label Text="Welcome to Xamarin.Forms!"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
<Button Text="click here" Clicked="Button_Clicked" />
private void Button_Clicked(object sender, EventArgs e)
{
Label.Text = "Hello World";
}
不知何故,系统不接受 .Text 作为标签的属性。
【问题讨论】: