Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Get Current Page Index and back to it

$
0
0

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 NoNet**workPage());


    }

    protected override void OnStart()
    {
        // if there is no connectivity it's going to go to no network page
        base.OnStart();
        CrossConnectivity.Current.ConnectivityChanged += HandleConnectivityChanged;
    }

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>