Ian Gallegos
Ian Gallegos

Reputation: 558

Stop WebView in Xamarin

I have an WebView in Xamarin and I need to visualize only one fix page. I set a page, but if from the webview I select a link, it change. I found the event Navigating, how can I stop the page before it starts loading?

.Xaml

<WebView x:Name="Browser" 
         VerticalOptions="FillAndExpand" 
         HorizontalOptions="FillAndExpand"
         Navigating="webOnNavigating" /> 

C#

void webOnNavigating(object sender, WebNavigatingEventArgs e)
{

}

Upvotes: 2

Views: 3206

Answers (1)

ColeX
ColeX

Reputation: 14475

You can cancel the current request in Navigating event.

void webOnNavigating(object sender, WebNavigatingEventArgs e)
{
     if (e.Url.StartsWith("xxx"))
     {
         e.Cancel = true;
     }
}

Upvotes: 7

Related Questions