Is WebView broken on Windows Phone in the dreaded 1.4.3.6358-pre2 build?

JohnHardmanJohnHardman GBUniversity mod

One of my pages that makes use of WebView was working across platforms prior to updating to 1.4.3.6358-pre2 . After updating, it now fails to display the webview on Windows Phone. Has anybody got WebView working on Windows phone with 1.4.3.6358-pre2 ?

        _webView = new WebView
        {
            Source = new UrlWebViewSource
            {
                Url = "http://www.google.com"
            },
            VerticalOptions = LayoutOptions.FillAndExpand
        };

        this.Content = new ScrollView
        {
            HorizontalOptions = LayoutOptions.Fill,
            VerticalOptions = LayoutOptions.Fill,
            Orientation = ScrollOrientation.Vertical,
            Content = _webView
        };

Answers

  • JohnHardmanJohnHardman GBUniversity mod
    edited May 2015

    Further investigation has identified an issue with WebView on WinPhone, whereby if the WebView is contained in a Layout type (e.g. StackLayout), and that Layout has LayoutOptions set, then the WebView ends up with Width and Height both equal to -1, so it doesn't get drawn.

    I've raised bug 30380.

    In the meantime, if you hit this, you can explicitly set the dimensions to workaround the problem on WinPhone.

    The following code can be used to demonstrate this, by commenting and uncommenting the HorizontalOptions line.

    using Xamarin.Forms;

    namespace FormsGallery
    {
    class WebViewDemoPage : ContentPage
    {
    public WebViewDemoPage()
    {
    WebView webView = new WebView
    {
    Source = new UrlWebViewSource
    {
    Url = "http://blog.xamarin.com/",
    },
    VerticalOptions = LayoutOptions.FillAndExpand
    };

            // Build the page.
            this.Content = new StackLayout
            {
                // Uncomment the below line and this will fail on WinPhone
                //HorizontalOptions = LayoutOptions.Start,
                Children = 
                {
                    webView
                }
            };
        }
    }
    

    }

Sign In or Register to comment.