【发布时间】:2020-05-08 21:28:35
【问题描述】:
我正在加载一个在 App.xlm.cs 中翻译许多句子的函数,然后在为我的 MainPage 充电之后。
问题是我的函数没有完成加载并显示 MainPage。
如何确保我的函数会被加载?
这是我在 App.Xml.cs 中的函数:
public async void SetLeafLanguage() // here is the function I would like to wait before display the MainPage
{
var phoneLanguage = "fr";// CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
// transversal
var WarningConnexionText = await MicosoftTranslater.TranslateText("this the first text", phoneLanguage);
// Test page
var NumberOfWords = await MicosoftTranslater.TranslateText("this the second text", phoneLanguage);
var ExerciceTitle = await MicosoftTranslater.TranslateText("this the second text", phoneLanguage);
var AnswerPlaceHolder = await MicosoftTranslater.TranslateText("this the second text", phoneLanguage);
var LabelNumberOfWordToTranslate = await MicosoftTranslater.TranslateText("this the second text", phoneLanguage);
// parameter labels
var AboutUstext = await MicosoftTranslater.TranslateText("this the second text", phoneLanguage);
}
public void GetUserOnData()
{
SetLeafLanguage();
MainPage = new MainPage();
}
public App ()
{
InitializeComponent();
GetUserOnData();
}
【问题讨论】:
标签: c# xamarin.forms