How do you modify platform-specific properties from a Xamarin.Forms application?

advertisements

I have a Xamarin.Forms Portable Application which contains a Page with a WebView control on it.

public class MainPage : ContentPage
{
    private WebView webView;

    public MainPage()
    {
        Content = (webView = new WebView());
    }
}

The WebView class is implemented differently on each platform -- each platform has it's own set of extra properties. For example on iOS, the WebView control is rendered as a UIWebView control, which has additional platform specific properties, some of which are not surfaced via the WebView class.

I would like to set some of those properties on a specific WebView control when my app is running on iOS. (Likewise, I'd like to do the equivalent for the Android, and UWP projects as well; as well as for other Xamarin.Forms controls that are not WebViews.)

So, how do you set the properties of those platform specific controls in Xamarin.Forms?


You either need to create a custom renderer, or use Effects to set platform specific properties.