Here are the steps:
Step 1: Firstly, we'll create our
Universal Windows Blank Project and name it according to our choice.
Step 2: The next thing we'll do in our project is to define our Grid Rows using
Grid.RowDefination. In my case I've used two rows: one for our browser display and the other is for search box and search button.
- <Grid.RowDefinitions>
- < RowDefinition Height="*">
- < /RowDefinition>
- < RowDefinition Height="0.1*">
- < /RowDefinition>
- < /Grid.RowDefinitions>
Step 3: The interesting thing we are going do in our project is to add one new control, that is WebView. The purpose of this control is to display your html web pages in your application. You must name your WebView control in your project.
- <WebView Name="mywebview" />
Step 4: The next thing is to add a TextBox in which you type some Url.
- <TextBox Name="searchbox1" Grid.Row="1" PlaceholderText="Search here" FontSize="18"
- Width="250" HorizontalAlignment="Left" />
Now create a button click event for your search button. Once you create a button click event then you've to go to the backend of your XAML page i..e., your csharp page.
- <Button Name="searchbtn" Grid.Row="1" Click="searchbtn_Click"
- HorizontalAlignment="Right"
- Width="100" Height="80" Content="Search"
- FontSize="25" FontWeight="Bold" />
Step 5: Once you enter in your button, click event, then you must declare a
string variable and assign your
TextBox name to it along with
Text property.
- string site = searchbox1.Text;
Step 6: The next thing is you call the
Navigate method along with your
WebView name and pass the string variable into Navigate method along with
UriKind Absolute.
- mywebview.Navigate(new Uri(site,UriKind.Absolute));
Step 7: Now run the app by pressing
F5. Now go to your searchbox and type some URL and press your button -- whatever name you gave to it -- and your result will display in webview.