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

App breaks while setting Application.Current.MainPage on a detail page.

$
0
0

Hello Eeveryone,

I am facing an issue while trying to set Application.Current.MainPage from a ContentPage which is a detail page.

Below is the use case:

I have a Dashboard page which has a ListView with DataTemplate of "ViewCell" type. The code redirects a user to a ContentPage using PushAsync on a button click. Below is the code snippet:

var navigation = (App.Current.MainPage as MasterPage).Detail.Navigation;
Device.BeginInvokeOnMainThread(() =>
{
    dialog.Hide(); navigation.PushAsync(new QuestionnairePage()); 
});

So when navigated back to Dashboard page it breaks the app when below lines of code is executed.

protected async override void OnAppearing()
{
    if(!MyBase.IsConnected())
    {
        Device.BeginInvokeOnMainThread(() =>
        {
            Application.Current.MainPage = new NoNetworkPage();
        });
        return;
    }
}

Can please anyone suggest me a solution or let me know where i am going wrong.

Regards,
Mehul Bhadricha


Viewing all articles
Browse latest Browse all 77050

Trending Articles



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