Page 1 of 1

Embed WebPage using Frame

Posted: Fri Apr 20, 2018 3:44 am
by ray6402
Hi

How do I embed a webpage in XAML using <Frame>?

I currently have:

Code: Select all

<StackPanel Margin="10">
        <Frame Source="https://www.google.co.za"/>
</Stackpanel>


In the XAML Designer I can see it loading the webpage, however in the Simulator I only get a blank screen.

Drilling down into the Visual Tree, I see that the Frame <Source> is "null"
Visual Tree.png
Visual Tree.png (5.26 KiB) Viewed 9140 times

Then when I run it in the Chrome browser, I get the same as the simulator.

Drilling down into the html code, I see that the Frame does not have a <Source> property.
HTML.PNG
HTML.PNG (17.34 KiB) Viewed 9140 times

Am I doing something wrong?

Re: Embed WebPage using Frame

Posted: Sun Apr 22, 2018 11:55 pm
by JS-Support @Userware
Hi,

Please use the <WebView> control for that. (Note: in SL Migration projects, it's called "<WebControl>".

Regards,
JS-Support

Re: Embed WebPage using Frame

Posted: Wed Apr 25, 2018 4:53 am
by ray6402
Hi,

I tried using the <WebView> control as follows:

Code: Select all

    <Grid Margin="10">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="5"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Button Grid.Row="0"
                Content="webview nav"
                Click="Button_Click"/>
        <WebView Grid.Row="2"
                 x:Name="TestWeb"/>
    </Grid>


By clicking on the button, you should show the Google homepage in the remaining area.

Code: Select all

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            TestWeb.Navigate(new Uri("https://www.google.co.za"));
        }


In the designer, it shows:
Designer.PNG
Designer.PNG (1.04 KiB) Viewed 9110 times


When I run the code, nothing happens on button click.
I tried using TestWeb.NavigateToString() as an alternative and that only shows a the URI string instead of the actual webpage.

Can you provide me with an example of how the <WebView> Control should be used instead?