I have a WebView object created in Xamarin.Forms:
WebView webView = new WebView {
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand
};
I need to do some platform-specific operations on this object: call some functions that aren't available in Xamarin.Forms because of different nature of this on different platforms.
The problem is, when I pass the Xamarin.Forms object:
public interface IWebViewCallCSharp
{
void passWebView(WebView webView);
}
I can do on "native side" exactly the same things as I could in Xamarin.Forms. How can I get some platform-specific functions of WebView on each platform? How to convert this to this ?
You will need to implement a so-called custom renderer. Start here: Implementing a HybridWebView .
In short you will need to:
In the last step you need to
The starting point where you begin using native controls is the OnElementChanged
override.
protected override void OnElementChanged (ElementChangedEventArgs<NativeListView> e)
{
base.OnElementChanged (e);
if (Control == null) {
// Instantiate the native control and assign it to the Control property
}
if (e.OldElement != null) {
// Unsubscribe from event handlers and cleanup any resources
}
if (e.NewElement != null) {
// Configure the control and subscribe to event handlers
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.