How can I use the WhileCanGoBack on Webview?

Hello, guys.

I’m trying to ue the webview. and use the back button and forward button. I have some question. If I push the goback button, It moves the blank page. So, I tried to add this WhileCanGoBack block. How can I use the WhileCanGoBack on Webview?

This is current code, and this code will not work.

                <Button Text="Back">
                    <Clicked>
                        <WhileCanGoBack>
                            <GoBack TargetNode="myWebView" />
                        </WhileCanGoBack>
                    </Clicked>
                </Button>

solve this problem please.

Hi! Try to invert your trigger order, <WhileCanGoBack> outside the <Clicked>.

Anders Lassen wrote:

Hi! Try to invert your trigger order, <WhileCanGoBack> outside the <Clicked>.

I tried to invert the trigger order. but it not worked. I think that WhileCanGoBack is not connect the canGoBack() function of Webview. Can you check this code please?

            <Button Text="Back">
                <WhileCanGoBack>
                    <Clicked>

                        <GoBack TargetNode="myWebView" />

                    </Clicked>
                </WhileCanGoBack>
            </Button>

Are you sure that your <WhileCanGoBack> has the WebView as its NavigationContext?

Could you try

<WhileCanGoBack NavigationContext="yourWebVeiw">

Unfortunately, It doesn’t excuted.

The node ‘myWebView’ can not be used here: The type must be compatible with ‘Fuse.Navigation.INavigation’ - /Users/sean/Desktop/testwebview/MainView.ux(4:1):E

Object reference not set to an instance of an object - (0:0):E

Below is my full source code.

  <DockPanel>
      <Panel Dock="Top" Height="50" Background="#ddd" Navigation="nav" HitTestMode="LocalBoundsAndChildren">
          <WhileCanGoBack NavigationContext="myWebView">
              <Button ux:Name="backButton" Text="Back" Alignment="Left" Width="50">
                  <Clicked>
                      <GoBack TargetNode="myWebView"/>
                  </Clicked>
              </Button>
          </WhileCanGoBack>
      &lt;Panel Width=&quot;100&quot;&gt;
          &lt;Text Value=&quot;{Page Title}&quot; FontSize=&quot;24&quot; Alignment=&quot;Center&quot;/&gt;
      &lt;/Panel&gt;
  &lt;/Panel&gt;
  &lt;Panel&gt;
      &lt;Page Background=&quot;Blue&quot; Title=&quot;Webview Page&quot; &gt;
          &lt;HierarchicalNavigation ux:Name=&quot;nav&quot;/&gt;

          &lt;NativeViewHost&gt;
              &lt;WebView ux:Name=&quot;myWebView&quot; Url=&quot;http://fusetools.com&quot; Dock=&quot;Fill&quot;&gt;                        
              &lt;/WebView&gt;
          &lt;/NativeViewHost&gt;
      &lt;/Page&gt;
  &lt;/Panel&gt;


I don’t know how can I connect to the Navigation system. Could you let me know if you can fix this source code?

Kristian Hasselknippe wrote:

Are you sure that your <WhileCanGoBack> has the WebView as its NavigationContext?

Could you try

<WhileCanGoBack NavigationContext="yourWebVeiw">

What version of Fuse are you using?

Kristian Hasselknippe wrote:

What version of Fuse are you using?

I using 0.12.4 version. Also I did “uno clean”.

Hey, thank you for your persistence and patience. This is a bug and has been found and squashed. The fix should make it into a release soon.

Thank you so much!