是否可以转到另一个页面,等到用户returns到原来的页面,然后继续该功能?

Is it possible to go to another page, wait until the user returns to the original page, then continue the function?

我正在为用户提供一个页面来编辑列表视图项目的内容。

public async void OnEdit(object sender, EventArgs e)
{
    var menuItem = ((MenuItem)sender);

    if (menuItem != null)
    {
        var selectedZone = (ViewModels.ZoneViewModel)menuItem.CommandParameter;

        // Send to edit page with selectedzones' contents.
        await Navigation.PushAsync(new ZonePage(selectedZone.Name, selectedZone.Address, selectedZone.IdentitySource, selectedZone.Username, selectedZone.Password));

        //Wait until user returns from page

        //Edit logic here
    }    
}

这是将用户带到那里的上下文操作。因此,在将用户发送到另一个页面后,我想等到他在编辑页面上完成编辑,然后 return 完成该功能。

我本来打算用不同的方式来做这件事,但结果并不是我想要的。我需要 var menuItem = ((MenuItem)sender); 才能从列表中获取所选项目,但不知道在我的情况下如何使用其他方法。

这可能吗?

您可以尝试MessagingCenter在两个页面之间进行通信。 Xamarin.Forms MessagingCenter 使视图模型和其他组件能够相互通信,除了简单的 Message 协定外,无需了解彼此的任何信息。

要通过消息传递参数,请在订阅通用参数和操作签名中指定参数类型。

    MessagingCenter.Subscribe<MainPage, string> (this, "Hi", (sender, arg) => {
    // do something whenever the "Hi" message is sent
    // using the 'arg' parameter which is a string
});

要发送带参数的消息,请在 Send 方法调用中包含 Type 泛型参数和参数值。

MessagingCenter.Send<MainPage, string> (this, "Hi", "John");

Here is the more detailed official documentation with examples.