Xamarin learning road 1. Embedding web pages, xamarin Road
Embed Web pages with Xamarin
1. Create a page, as shown in figure
The corresponding page code is as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
<ContentPage xmlns = "http://xamarin.com/schemas/2014/forms"
Xmlns: x = "http://schemas.microsoft.com/winfx/2009/xaml"
X: Class = "App_ERP.View.Core.Views.UseWebView">
<ContentPage. ToolbarItems>
<ToolbarItem Text = "refresh" Command = "{Binding RefreshCmd}"/>
</ContentPage. ToolbarItems>
<StackLayout>
<Label Text = "{Binding MainText}"/>
<WebView Source = "{Binding DataSource }"
HeightRequest = "1000"
WidthRequest = "1000" type = "codeph" text = "/codeph"/>
</StackLayout>
</ContentPage>
2. The model code corresponding to the background
[MasterItem]
Public class UseWebViewModel
{
Public string MainText {get; set ;}
Public string DataSource {get; set ;}
// Refresh the event
Public ICommand RefreshCmd {get; set ;}
Public UseWebViewModel (SimpleContainer container)
{
DisplayName = "embedded webpage ";
Icon = "icon_setting.png ";
MainText = "holle word ";
DataSource = "https://www.baidu.com ";
// Refresh the event
This. RefreshCmd = new Command () => this. LoadData ());
}
Public async void LoadData ()
{
Required yofpropertychange () => this. DataSource );
}
For example, I will continue to refuel later,