Issue
I have tried this but it does not work
private async void SignUpLink_OnTapped(object sender, EventArgs e)
{
await Navigation.PopModalAsync();
await Navigation.PushModalAsync(new SignUp());
}
Solution
It is possible . You can use delegate to realzie it .I will show a sample with MainPage/SecondPage/ThirdPage to show it.
Define a delegate in PageA and method to invoke it :
public partial class MainPage : ContentPage
{
//declare a delegate in MainPage
public delegate void MyDelegate(bool val);
public MainPage()
{
InitializeComponent();
}
async private void Button_Clicked(object sender, EventArgs e)
{
// navigate to second page with delegate
await Navigation.PushModalAsync(new SecondPage(DeleagteVoid));
}
// invoked by poping back
private async void DeleagteVoid (bool value)
{
//When delegate method invoked , by value to determine whether to push to next page
Console.WriteLine("---" + value);
if (value)
{
// if true , push to third page
await Navigation.PushModalAsync(new ThirdPage());
}
}
}
SecondPage when poping to previous page invoke delegate
method which in MainPage
:
public partial class SecondPage : ContentPage
{
// declare delegate also in second page
MyDelegate myDelegate;
public SecondPage(MyDelegate deleagteVoid)
{
InitializeComponent();
// assign delegate
this.myDelegate = deleagteVoid;
}
private async void Button_Clicked(object sender, EventArgs e)
{
// pop to previous page
await Navigation.PopModalAsync();
//invoke delegate method in MainPage
myDelegate(true);
}
}
ThirdPage do other you want .
Answered By - Junior Jiang
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.