I tried to reproduce your issue to put a WebView
inside a ScrollerView
directly as you described like follows but I cannot reproduce:
<ScrollViewer>
<WebView Source="http://microsoft.com" x:Name="WebViewControl" ></WebView>
</ScrollViewer>
But I found I can reproduce your issue with code like follows:
<StackPanel>
<Image Source="Assets/caffe1.jpg" Stretch="None" ></Image>
<WebView Source="http://microsoft.com" x:Name="WebViewControl" ></WebView>
</StackPanel>
For this scenario, I resolved the issue which webview cannot visible by adding the MinHeight
property of WebView like follows:
<WebView Source="http://microsoft.com" x:Name="WebViewControl" MinHeight="400"></WebView>
If you try to get the ActualHeight
in your scenario after the WebView
navigation completed by the following code, you will find the result may be 0, which may be the reason the WebView
cannot be visible. Since there is one more controls inside one container and we don't set height for these controls, height will be calculated automatically for each control. The height is set automatically by the content of the control. WebView
need time to load content which may lead issues with height calculating.
WebViewControl.NavigationCompleted += WebViewControl_NavigationCompleted;
private void WebViewControl_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
{
System.Diagnostics.Debug.WriteLine("Actual height of webview:" + WebViewControl.ActualHeight);
}
By the way, if you want to set the height depended on the content you can reference this thread.