获取ContentPage中更改的int的结果

时间:2017-11-27 02:17:24

标签: c# xamarin

我有一个具有以下页面结构的应用程序:

PreloaderService.hidePreLoader();

所有页面都是ContentPages。

InputLanguagePage和OutputLanguagePage是完全相同的页面,因此我不想两次对同一页面进行编程。

我可以肯定地将同一页面实例化两次,但我不知道应该如何获得返回值。

我花了很长时间试图描述我的问题。 也许下面的代码更好地证明了问题。

正如您所看到的,我似乎无法获得LanguageSelectionPage的返回值,因为它显示为异步。 将其更改为Navigation.PushModalAsync()也没有改变任何内容。

让ContentPage返回值或更改值并获得通知的最佳方法是什么?

谢谢。

的MainPage:

MainPage
        ->SettingsPage
                      ->InputLanguagePage
                      ->OutputLanguagePage

SettingsPage:

public class MainPage : ContentPage
{
    private async void OnSettingsSelected(object sender, EventArgs e)
    {
        SettingsPage nSettings = new SettingsPage();
        await this.Navigation.PushAsync(nSettings);
    }
(...)

LanguageSelectionPage:

public class SettingsPage : ContentPage
{
    public SettingsPage()
    {
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            _btnInputLanguage.Clicked += async (sender, e) =>
            {
                LanguageSelectionPage nInputLanguage = new LanguageSelectionPage();
                nInputLanguage.SelectedLCID = App.Settings.InputLanguageLCID;
                await Navigation.PushAsync(nInputLanguage);
                //The user can change "int SelectedLCID" within the ContentPage, but I have no idea how I could access it
                return;
            };

            _btnOutputLanguage.Clicked += async (sender, e) =>
            {
                LanguageSelectionPage nOutputLanguage = new LanguageSelectionPage();
                nOutputLanguage.SelectedLCID = App.Settings.OutputLanguageLCID;
                await Navigation.PushAsync(nOutputLanguage);
                //The user can change "int SelectedLCID" within the ContentPage, but I have no idea how I could access it
                return;
            };

(...)

(...)

0 个答案:

没有答案