Introduction: Coding Web Browser for Windows 10 IOT on Raspberry PI 2

As per the the video tutorial you would need to download Visual Studios 2015 Community

https://dev.windows.com/en-us/downloads

Step 1: Lets Look at the Code

The code for this sample is pretty simple:

  • An embedded webview control
  • TextBox as address bar
  • Go Button to start Navigation

when go button is pressed we call a web navigation helper method to do the actual navigation

Step 2: UX Code

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid.RowDefinitions> <RowDefinition Height="65"></RowDefinition> <RowDefinition Height="*"></RowDefinition> </Grid.RowDefinitions> <!--Address bar--> <StackPanel Grid.Row="0" Orientation="Horizontal"> <TextBox x:Name="Web_Address" FontSize="24" TextWrapping="Wrap" Text="http://www.youtube.com" VerticalAlignment="Center" VerticalContentAlignment="Center" Height="54" Width="958" KeyUp="Web_Address_KeyUp"/> <Button x:Name="Go_Web" Content="Go!" HorizontalAlignment="Right" VerticalAlignment="Center" Height="60" Width="107" Click="Go_Web_Click"/> </StackPanel>

<!--Web view control--> <WebView x:Name="webView" Grid.Row="1" /> </Grid>

Step 3: Main Code C#

private void Go_Web_Click(object sender, RoutedEventArgs e)
{ DoWebNavigate(); }

private void Web_Address_KeyUp(object sender, KeyRoutedEventArgs e) { if (e.Key == Windows.System.VirtualKey.Enter) { DoWebNavigate(); } }

private async void DoWebNavigate() { try { if (Web_Address.Text.Length > 0) { webView.Navigate(new Uri(Web_Address.Text)); } else { MessageDialog dlg = new MessageDialog("you need to enter a web address."); await dlg.ShowAsync(); } } catch (Exception e) { MessageDialog dlg = new MessageDialog("Error: " + e.Message); await dlg.ShowAsync();

} }

Comments

About This Instructable

6,546views

24favorites

License:

Bio: Avid Thinker, Computer Programmer, Web evangelist, Hacking / Breaking expert, Problem Solver, Technology Obsessed, Gamer, 3D printing, Coffee lover!
More by novaspirittech:Voice Activated Google Assistant for Raspberry PiGoogle Assistant on a Raspberry PiButton Trigger for Google Assistant on the Raspberry Pi
Add instructable to: