question

SudhaSub avatar image
0 Votes"
SudhaSub asked RoyLi-MSFT commented

[UWP] WebView height gets wrong height randomly

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

windows-uwp
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

It seems the issue hasn't been solved yet. Could you please submit feedback in the Feedback Hub as well. You could find the Feedback Hub in the Start Menu.

1 Vote 1 ·

0 Answers