Xamarin Stacklayout没有被填充

本文关键字:填充 Stacklayout Xamarin | 更新日期: 2023-09-27 18:16:59

我在屏幕上有一个Stacklayout,它在不同的时间用代码后面的标签填充。

问题是,我有这个方法不填充Stacklayout。它使用与其他方法相同的代码。它成功地运行了代码,但是没有显示在屏幕上。

'readout'是Stacklayout。

public async void HandleNFC(string convertedtag)
{
    PeopleLocationsForUserRoot peoplelocationforuser = await WebDataAccess.GetPeopleLocationForUser("ConroyJ", 1);
    Label label1 = new Label { Text = "Successfully clocked out @ " + convertedtag, TextColor = Color.Black };
   readOut.Children.Add(label1);
   DisplayAlert("NFC", convertedtag, "cancel");
}

Xamarin Stacklayout没有被填充

在表单应用程序中,你可以像这样获得对主页的引用

  App.Current.MainPage
为了调用自定义方法 ,您还需要正确地强制转换它
  var main = (MyMainPageType) App.Current.MainPage;
  main.HandleNFC(data);