Introduction:
Hello friends,In this blog we work on WebView control and create custom renderer in each platform specification for enhancement a pinch feature.
Programming:
Core:
In forms project,we will create our MyWebView class and inherit it from Xamarin.forms.WebView class.this is the WebView class of Xamarin technology.now our MyWebView have all the features and properties of Xamarin.forms.WebView.
using System;
namespace Demo.Renderer
{
public class myWebView:Xamarin.Forms.WebView
{
}
}Xamarin.droid:
Here,we create a custom Renderer in droid solution and Export this renderer to our custom WebView.
using System;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Webkit;
using Android.Widget;
using Demo.Droid;
using Demo.Renderer;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(myWebView), typeof(Demo.Droid.myWebViewRenderer))]
namespace Demo.Droid
{
public class myWebViewRenderer: WebViewRenderer
{
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (Control != null)
{
Control.Settings.BuiltInZoomControls = true;
Control.Settings.DisplayZoomControls = true;
}
base.OnElementPropertyChanged(sender, e);
}
}
}Xamarin.ios:
Here We create custom Renderer for Xamarin.ios.this cutom renderer uses the native webview for adding pinch feature.
using System;
using Demo.Renderer;
using Foundation;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(myWebView), typeof(Demo.iOS.myWebViewRenderer))]
namespace Demo.iOS
{
class myWebViewRenderer:WebViewRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (NativeView != null && e.NewElement != null)
{
var webView = ((UIWebView)NativeView);
webView.ScalesPageToFit = true;
}
}
}
}
Thanks..
ReplyDeleteNice Blog. well explained each and every concepts.keep sharing.
ReplyDeleteData Science Training Course In Chennai | Data Science Training Course In Anna Nagar | Data Science Training Course In OMR | Data Science Training Course In Porur | Data Science Training Course In Tambaram | Data Science Training Course In Velachery
fine blog and honestly awesome. you could lead your hands for your palms on grip of some thing a good deal stepped forward however i nonetheless make known this affiliation maintain infuriating for the best.! Virtual Audio Cable Trial Annoying
ReplyDeletei discovered your this make recognized even though attempting to find statistics roughly blog-connected research ... it is a big pronounce .. desist posting and updating point out.! Microsoft Office 2010 Crack Free Download
ReplyDeletekralbet
ReplyDeletebetpark
tipobet
slot siteleri
kibris bahis siteleri
poker siteleri
bonus veren siteler
mobil ödeme bahis
betmatik
37NF0
شركة مكافحة النمل الابيض بالدمام ZkWiiOaZC1
ReplyDelete