有没有办法回到导航堆栈中的最后一页,而不是在Xamarin中执行veraperation方法?
因此,我拥有page1
,其中一些输入字段已经填写,并且有一个按钮打开一个新页面(让我们称其为page2
)。
这是我用来使用page2
的代码。
Application.Current.MainPage.Navigation.PushModalAsync(new NavigationPage(new Page2()));
这是我过去回到page1
上的代码。
private async void GoBackButton_Clicked(object sender, EventArgs e)
{
await Application.Current.MainPage.Navigation.PopModalAsync();
}
现在,我想以某种方式,当用户完成他在page2
上的内容时,他按下按钮,称为gooback
,然后他回到上。 page1
,
page1
的viewModel的方法是 not 被执行。这可行吗?
不确定是否重要,但是我在Windows10上使用VS22。
So, I have Page1
, with some input fields that my user already filled, and, there is a button that opens a new Page (let's call it Page2
).
This is the code I used to go on Page2
.
Application.Current.MainPage.Navigation.PushModalAsync(new NavigationPage(new Page2()));
This is the code I used to came back on Page1
.
private async void GoBackButton_Clicked(object sender, EventArgs e)
{
await Application.Current.MainPage.Navigation.PopModalAsync();
}
Now, I'd like to, somehow, when user finishes what he had on Page2
, he presses the button, called GoBack
, then he comes back on the Page1
, and the OnApearing
method of Page1
's ViewModel is NOT getting executed. Is this doable?
Not sure if important, but I'm using VS22, on Windows10.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是我在某些应用中使用的。逻辑是:Page1在第一个加载上加载数据,然后在请求重新加载时仅重新加载数据。
这是一个示例:
page1.xaml.cs
page2.xaml.cs
This is what I'm using in some of my apps. The logic is: Page1 loads data on the first load and then only reloads data when reload requested.
Here's an example:
Page1.xaml.cs
Page2.xaml.cs