I've just started working on Xamarin. So, i've created a page which checks if there is an internet connection available or not in Xamarin at the very starting of opening the app.If not , i show a DisplayAlert for user.
Since, it is a page
DisplayAlert("No Internet Connection","Please check your internet connection","ok");
should work. But,it is not working.I've to use
Application.Current.MainPage.DisplayAlert("No Internet Connection","Please check your internet connection","ok");
to make it working. As far as i've read, Application.Current holds the information of current app. But what kind of infomation and what is MainPage ? How DisplayAlert is found inside MainPage ? And important one: I'm already inside a Page,so why do i need to use Application.Current.MainPage to call DisplayAlert ?
I've gone through these links(but the documentation is poor):
[Can't post link as i need to be around here little while longer]
So,my question is:
What is Application.Current?
What is Application.Current.MainPage?
Why do i need to use Application.current.MainPage to call DisplayAlert ? I'm already inside a page,so DisplayAlert should be call directly?
In the past , directly calling "DisplayAlert" worked.I never needed to use Application.Current.MainPage