Navigation in WebView

So I have a little webview to display a youtube feed (only a quick test) but I can’t seem to find out how to navigate within it.

I’d like to go back to the previous page when the user presses the back button but it doesn’t work?

Here’s the code:

<StackPanel>
  <Button Text="Back">
      <Clicked>
          <GoBack TargetNode="Videos"/>
      </Clicked>
  </Button>

  <NativeViewHost Height="420" Alignment="BottomCenter">
      <WebView ux:Name="Videos" Dock="Fill" Url="https://www.youtube.com/channel/UCfSmFFIZsuPSHoiEVhnSkJA/videos">
          <LinearNavigation/>

          <!--OnBackButton>
              <GoBack TargetNode="Videos"/>
          </OnBackButton-->
      </WebView>
  </NativeViewHost>
</StackPanel>

Hey Casey, what platform are you testing on?

Hi Andreas, I’ve tested on builds and preview on my Android device and neither work.

I’m testing here on my Nexus 5 and it does work. I made some slight alterations to your code for comfort:

<App Theme="Basic" Background="#333333ff">
    <ClientPanel>
        <Button Text="Back" Dock="Top">
            <Clicked>
                <GoBack TargetNode="Videos"/>
            </Clicked>
        </Button>
        <NativeViewHost>
            <WebView ux:Name="Videos" Url="https://www.youtube.com/channel/UCfSmFFIZsuPSHoiEVhnSkJA/videos"&gt;
                <!-- No need for a linearnavigation here, the WebView is one -->
                <OnBackButton>
                    <!-- No need for TargetNode here, containing the GoBack in a navigation (webview in this case) is enough -->
                    <GoBack /> 
                </OnBackButton>
            </WebView>
        </NativeViewHost>
    </ClientPanel>
</App>

I think your problem might be that youtube doesnt actually change its URL that often when you click on tabs and stuff, only when you actually go to a new page such as when you look at a video. Tapping a video and opening it and then hitting back works for me, for both UI button and device button.

Okay many thanks, I’ll check it out later!:slight_smile: