Hi,
I have loaded html content on a web view and tried to set the webview height using "ScriptNotify" and "NavigationCompleted" events. I need to do some UI related stuff depending on webview height like showing a button, enabling/disabling button, etc.
But sometimes I notice, it gets more height than it requires when opening the webview and it shows cached UI explained above. Seems like it requires a considerable delay to open a webview one after another.
private async void NCWRWebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
{
int heightScroll = 0;
var heightScrollStr = await webView.InvokeScriptAsync("eval", new[] { "document.body.scrollHeight.toString()" });
if (int.TryParse(heightScrollStr, out heightScroll))
{
webView.Height = heightScroll;
}
if (webView.Height > scroll.ActualHeight)
{
addButton.Visibility = Visibility.Visible;
cancelButton.IsEnabled = false;
else
{
addButton.Visibility = Visibility.Collapsed;
cancelButton.IsEnabled = true;
}
}
I found similar thread to this. https://social.msdn.microsoft.com/Forums/en-US/4b09e2e1-90bc-4135-82fc-10d9067f0c6b/cuwpwebviewhow-to-resize-webview-height-based-on-html-content-in-windows-10-uwp?forum=wpdevelop
Is this issue addressed recently or is there any way to fix this issue?
Thanks