In my Xamarin Forms app, I have a custom view that derives from ContentView. On iOS and macOS, I would like to replace this view with a native control ([UI|NS]SegmentedControl). So I created a renderer that derives from ViewRenderer and implemented it.
It's working, but there is a flaw. The original Forms control (known as Element within the renderer) is displaying behind the UISegmentedControl. My expectation is that only the native control would be rendered when using ViewRenderer.
Any changes made to the appearance of the Forms element are reflected on the native control, so simply hiding it or making it transparent won't work.
Here's my iOS renderer.
public class CustomContentViewRenderer : ViewRenderer<CustomContentView, UISegmentedControl>
{
protected override void OnElementChanged(ElementChangedEventArgs<CustomContentView> e) {
base.OnElementChanged(e);
if (e.NewElement != null ) {
if ( Control == null )
SetNativeControl(new UISegmentedControl(new string[] { "One", "Two", "Three" }));
}
}
}
CustomContentView here is simply derived from ContentView with a BoxView as content. Here's what it looks like on iOS:

My understanding of renderers is that a custom renderer completely overrides the forms element. Am I missing something big here? Can ViewRenderer<> be used to completely replace a Xamarin ContentView with a native control?
EDIT: In the sample above I'm using a BoxView as a placeholder for the actual cross platform picker I use for UWP. The real control is a StackLayout containing toggle buttons. Here's a screen grab on macOS showing the issue.
In the end, setting Element.Content.IsVisible = false worked.
