Here i am working with Xaml & C#. and i am using a webview to show some html, its working perfect but there is a problem i am facing is that how to make tag clickable of that Html content.
Thanks for any Help in Advance.
答案 0 :(得分:1)
点击<a>
中的WebView
代码后,系统会触发WebView.NavigationStarting event。在这种情况下,我们可以获得WebViewNavigationStartingEventArgs
,其中包含<a>
标记中的URI。所以我认为您可以使用它来导航到您的作者简介详细信息页面。因为我不知道你的<a>
标签是如何实现的。这里我只使用一个简单的演示。
在XAML代码中:
<WebView NavigationStarting="WebView_NavigationStarting"
Source="https://blogs.windows.com/buildingapps/2016/07/13/introducing-new-remote-sensing-features-2/" />
在代码隐藏中:
private void WebView_NavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
{
//Add some logic to determine if we need to navigate to AuthorProfileDetailPage
//and which author's profile need to be shown
if (args.Uri.AbsoluteUri == @"https://blogs.windows.com/buildingapps/author/windowsappsteam/")
{
//Cancel the navigataion in WebView
args.Cancel = true;
//Navigate to AuthorProfileDetailPage with the parameter
//in AuthorProfileDetailPage we can use this parameter to determine which author's profile need to be shown
this.Frame.Navigate(typeof(AuthorProfileDetailPage), args.Uri.Segments.Last());
}
}
这是一个简单的示例,您可以自己实现逻辑。希望这会有所帮助。