WebView
A WebView is a control for displaying HTML (HyperText Markup Language) or web content.
<StackLayout Margin="10">
<WebView x:Name="webView"
Source="https://mauiman.dev" />
</StackLayout>
Specify the Source property to a URL string to display a website from the internet. Alternatively, the Source can be set in C# code.
Code Behind
public MainPage()
{
InitializeComponent();
webView.Source = "https://mauiman.dev";
}
WebView loading local HTML/Web File - NOT WORKING
Create a Raw folder in Resources and add an index.html with the following content:
<html>
<head>
<title>.NET MAUI Local HTML Web</title>
</head>
<body>
<h1>.NET MAUI Local HTML Web</h1>
<p>.NET MAUI Local HTML Web.</p>
</body>
</html>
Set the BuildAction of index.html to MauiAsset. If you edit the project file, you should see the following tag attribute.
<ItemGroup>
<MauiAsset Include="Resources\Raw\index.html" />
</ItemGroup>
Set the the Source of the WebView to the following and run the project
<StackLayout Margin="10">
<WebView x:Name="webView"
Source="index.html" />
</StackLayout>
Download