Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
When I try to write a custom renderer for any of the layout classes, the "Control" property appears null. It is OK since the renderer already is the wrapper for the native control but it is a problem when creating an Effect. So I cannot do any customization with the layout classes using Effects since Control property is not assigned.
Can you upload a project example of what you're attempting to do? Are you using SetNativeControl() at all?
I am not using SetNativeControl. You can create a barebone custom renderer class for a ContentView and AbsoluteLayout to try debugging the Control property. It will always be null.
It is not a problem for custom renderers because we can access the corresponding native View since the renderer inherits from it but that is not the case for Effects.
You should use SetNativeControl. Similar to the docs (https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/custom-renderer/view/#Creating_the_Custom_Renderer_on_Android), you can have a custom renderer inherit from ViewRenderer<AbsoluteLayout, Android.Views.View> like this:
public class TestLayoutRenderer : ViewRenderer<AbsoluteLayout, AView>
protected override void OnElementChanged(ElementChangedEventArgs<AbsoluteLayout> e)
if (Control == null)
var view = new AView(this.Context);
I've just used this and the Control is not null after calling SetNativeControl.
I was familiar with that approach for complex renderers where the author is adding native controls into the renderer but I was thinking of a simple AbsoluteLayout renderer similar to a ButtonRenderer.
For example when I create a button renderer, Control property is already set, I don't have to do anything. I thought layouts would be the same. But apparently I am mistaken. Thanks for the clarification.
I am using a ContentView render without setting any native controls. So now I wonder, how does that work? Should I be setting a native AView for that, too?
Is there a documentation or code sample that shows simple layout/contentview renderers for both Android and iOS? (Because I didn't know about AView etc. before, so such examples would be nice)