How to implement a webview in Xamarin.Forms

Web Viewis a handy component to load web content. In some cases, you want to display a single web page locally in your app or let users access external web pages within your app. You can simply embed the Web View object in your app and send it a request to load the web content.
In this demo we are going to implement a single webview in our application.
Let’s Start:
We are just simply going to add a label and a webview in our application demo.
Create a new Xamarin.Forms solution and name it as “WebViewXamarinForms”.
Create a new ContentPage file and name it as WebViewPage, add NavigationPage to it.
Now in WebViewPage.cs:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
public class WebViewPage : ContentPage { public WebViewPage () { Label lbl_header = new Label { Text = "WebView", HorizontalOptions = LayoutOptions.Center }; WebView webview = new WebView { Source = "http://google.com", VerticalOptions = LayoutOptions.FillAndExpand }; this.Content = new StackLayout { Children = { webview } }; } } |
Now try to build and run the app.
In iOS it will run without changes but for Android you have to add permission for Internet in AndroidMenifest.xml file.
If you like this tutorial then you can download full copy of the code from github.
how can we use the web services data in web view in xamarin.forms.
i want to interaction between webview in xamarin.forms and web services.