Achraf Ben Alaya

Achraf Ben Alaya

  • NA
  • 134
  • 4.2k

Xamarin navigation (current page)

Oct 18 2018 8:58 AM
I'm developing an application using xamarin forms , I have to check the connectivity , i'm using the connectivity plugin .
So , what I want , if there is no connection , I want to go to no navigation page , and after the navigation is back , I want to go back to the page where I was .
What I was able to do is , to go back to the main page of the application , doing this on my App.xaml.cs .
Is there any way I can go back to the page where Exactly I was ?!
 
public App()
{
InitializeComp*onent();
if (Device.Idiom == TargetIdiom.Tablet || Device.Idiom == TargetIdiom.Desktop)
MainPage = CrossConnectivity.Current.IsConnected ? (Page)new NavigationPage(new ClientPagetablet()) : new NoNetworkPage();
else
MainPage = CrossConnectivity.Current.IsConnected ? (Page)new NavigationPage(new ClientPage()) : new NoNetworkPage();
}
private void HandleConnectivityChanged(object sender, ConnectivityChangedEventArgs e)
{
Type CurrentPage = this.MainPage.GetType();
if (e.IsConnected && CurrentPage != typeof(ClientPage))
this.MainPage = new NavigationPage(new ClientPage());
else
if (!e.IsConnected && CurrentPage != typeof(NoNetworkPage))
this.MainPage = new NavigationPage(new NoNetworkPage());
}
protected override void OnStart()
{
// if there is no connectivity it's going to go to no network page
base.OnStart();
CrossConnectivity.Current.ConnectivityChanged += HandleConnectivityChanged;
}

Answers (1)