我正在尝试向标签添加名称,以便可以使用 Content.FindByName<>() 方法找到它
据我所知, Xamarin.Forms.Label() 类没有 Name 属性
这是我的页面类
public class HelloWordCodePage : ContentPage
{
public Label HelloWorldLabel;
public HelloWordCodePage()
{
HelloWorldLabel = new Label{Text = "Hello World", };
ConstructView();
}
public void ConstructView()
{
Content = new StackLayout
{
Children =
{
HelloWorldLabel
}
};
}
}