Step 1
Go to Visual Studio.
Click File -> New -> Project.
Click C# -> Cross Platform -> Cross Platform App (Xamarin.Forms.Portable).
Enter the Application Name, followed by clicking OK.
Step 2
In this step, go to Solution Explorer -> Portable Class Library, followed by clicking XAML, insert the code given below XAML page and save it.
Step 3
Open App.Xaml.cs and set the page name.
- <?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="TableExample.Page1">
- </ContentPage>
Step 4
Open Page1.Xaml.cs and add the code in this page.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- using Xamarin.Forms;
-
- namespace TableExample
- {
- public partial class Page1 : ContentPage
- {
- public Page1()
- {
- InitializeComponent();
- var browser = new WebView();
- var htmlSource = new HtmlWebViewSource();
- StringBuilder htmlStr = new StringBuilder("");
- htmlStr.Append("<html><body><table>");
- htmlStr.Append("<table width='100%' height='20%' Border='1px solid black'>");
-
- htmlStr.Append("<tr>");
- htmlStr.Append("<th> FirstName </th>");
- htmlStr.Append("<th>LastName </th></tr>");
-
- htmlStr.Append("<tr>");
- htmlStr.Append("<td>Disha </td>");
- htmlStr.Append("<td>Raval</td></tr>");
-
- htmlStr.Append("<tr>");
- htmlStr.Append("<td>Namrata</td>");
- htmlStr.Append("<td>Rathod</td></tr>");
-
- htmlStr.Append("<tr>");
- htmlStr.Append("<td>Monika</td>");
- htmlStr.Append("<td>Vaghasiya</td></tr>");
-
- htmlStr.Append("</table></body></html>");
- htmlSource.Html = htmlStr.ToString();
- browser.Source = htmlSource;
- Content = browser;
- }
- }
- }
Step 5
Click Build menu and go to Configuration Manager
Configure your Android, Windows, iOS Depoly & Build Setting, followed by clicking Close.
Step 6.
In this step, select Build & Depoly option, followed by clicking to Start your Application.
Now, go to Run option, choose Debug from the list of an Android or an iOS or UWP Simulators, which are available. You can choose any one Simulator and run it.
Step 7
Output
After few seconds, the app will start running on your Android Simulator. You will see your app is working successfully.