How to code an Web Browser for windows 10 IOT core on raspberry pi 2 with C#. Playing YouTube possibly netflix in the future? thanks for the view.
MainPage.xaml (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>
MainPage.xaml.cs
public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); } 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(); } } }
View Comments (0)