Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

WebViewRenderer Issue

$
0
0

Hi,

I developed simple project for show web site in webview.

These are my classes:

`public class WebPage:BasePage
{
public WebPage ()
{

        var stack = new StackLayout
        {
            Orientation=StackOrientation.Vertical,
            HorizontalOptions=LayoutOptions.FillAndExpand,
            VerticalOptions=LayoutOptions.FillAndExpand

        };

        var myWebView = new MyWebView ()
        {
            VerticalOptions=LayoutOptions.FillAndExpand,
            HorizontalOptions=LayoutOptions.FillAndExpand,
            Source="http://www.google.com/"

        };

        stack.Children.Add (myWebView);

        Content = stack;

    }
}`

`
[assembly: ExportRenderer( typeof( WebPage), typeof( WebPageRenderer))]
namespace Vodaxi.iOS
{
public partial class WebPageRenderer : WebViewRenderer
{

    private UIWebView _webView;
    protected override void OnElementChanged(VisualElementChangedEventArgs e)
    {

        base.OnElementChanged (e);
        if (e.OldElement == null) {   // perform initial setup
            var webView = (UIWebView)this.NativeView;

            webView.ScalesPageToFit = true;


        }
    }

}

}`

`public static class App
{
public static Page GetMainPage ()
{

        return new WebPage ();

    }
}`

But when i run project im getting this error:

Unable to cast object of type 'Vodaxi.WebPage' to type 'Xamarin.Forms.WebView'.

Where did i do wrong?

Thanks.

PS: Xamarin.forms version="1.2.3.6257"


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>