Introduction:
We know that WebView is a view for displaying web and HTML content in your app. Due to security, sometimes website links will not work with outside network, so we need to identify it to show custom dialog to user.
Description:
In Xamarin.Forms, WebView raises the following events to help you respond to changes in state:
In MainPage.xaml
In MainPage.xaml.cs
async void Browser_Navigated(object sender, WebNavigatedEventArgs e)
{
if (e.Result.ToString().ToLower() == "failure"){
await DisplayAlert("", "This site can’t be reached", "Ok");
}
}
We know that WebView is a view for displaying web and HTML content in your app. Due to security, sometimes website links will not work with outside network, so we need to identify it to show custom dialog to user.
Description:
In Xamarin.Forms, WebView raises the following events to help you respond to changes in state:
- Navigating – event raised when the WebView begins loading a new page.
- Navigated – event raised when the page is loaded and navigation has stopped.
- ReloadRequested – event raised when a request is made to reload the current content.
In MainPage.xaml
- <WebView Navigated="Browser_Navigated" />
In MainPage.xaml.cs
FeedBack Note: Please share your thoughts, what you think about this post, Is this post really helpful for you? I always welcome if you drop comments on this post and it would be impressive.
No comments:
Post a Comment