summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls/GalleryPages/WebViewGallery.cs
blob: c39e7777c206c6d267b5a05d82a0572bbc71a9f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Xamarin.Forms.Controls
{
	public class WebViewGallery : ContentPage
	{
		class ViewModel
		{
			public string Html { get; set; } = "<html><body><p>This is a WebView!</p></body></html>";

			public string Url { get; set; } = "http://xamarin.com";

		}

		public WebViewGallery ()
		{
			var htmlWebView = new WebView {
				HeightRequest = 40,
				//Source = new HtmlWebViewSource {Html ="<html><body><p>This is a WebView!</p></body></html>"}
			};
			var urlWebView = new WebView {
				VerticalOptions = LayoutOptions.FillAndExpand,
				//Source = new UrlWebViewSource {Url = "http://xamarin.com/"}
			};

			var htmlSource = new HtmlWebViewSource ();
			htmlSource.SetBinding (HtmlWebViewSource.HtmlProperty, "HTML");
			htmlWebView.Source = htmlSource;

			var urlSource = new UrlWebViewSource ();
			urlSource.SetBinding (UrlWebViewSource.UrlProperty, "URL");
			urlWebView.Source = urlSource;

			var viewModel = new ViewModel ();
			BindingContext = viewModel;

			Content = new StackLayout {
				Padding = new Size (20, 20),
				Children = {
					htmlWebView,
					urlWebView
				}
			};
		}
	}
}