Warning CS0618: 'PickerRenderer.PickerRenderer()' is obsolete: 'This constructor is obsolete as of version 2.5. Please use PickerRenderer(Context) instead.
This Warning is not only in picker renderer all renderers(Entry, DatePicker, StackLayout Renderer) are showing this warning. My custom renderer for Picker is like this,
public class BorderlessPickerRenderer : PickerRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
base.OnElementChanged(e);
var picker = e.NewElement;
if (Control != null)
{
Control.Background = null;
Control.SetTextSize(Android.Util.ComplexUnitType.Pt, 8);
Control.SetTextColor(Android.Graphics.Color.ParseColor("#141414"));
}
}
}
There is a new .ctor
for Xamarin.Forms
(2.5+) Android-based renderers that accepts an Android-based context. The older parameterless constructor have been marked obsolete in order to support native embedding.
Add this to your renderer:
public BorderlessPickerRenderer(Context context) : base(context)
{
}
According to 2.5.0 release notes you should add a constructor the next way:
public BorderlessPickerRenderer(Context context) : base(context) {}
In addition there is a dedicated thread on official Xamarin forums on this topic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With