I'm still learning how to write a custom control using custom renderer. Right now I'm stuck at getting the value of a bindable property in a custom control from a custom renderer. Could someone help me with this?
Thanks
Custom Control for TimePicker:
public class CustomTimePicker: TimePicker
{
public static readonly BindableProperty CustomFontSizeProperty =
BindableProperty.Create("CustomFontSize", typeof(string), typeof (CustomTimePicker), defaultBindingMode: BindingMode.OneWay);
}
Custom Renderer for TimePicker:
[assembly: ExportRenderer(typeof(CustomTimePicker), typeof(CustomTimePickerRenderer))]
namespace MYNS.Mobile.Droid
{
public class CustomTimePickerRenderer : TimePickerRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.TimePicker> e) {
base.OnElementChanged(e);
if (e.OldElement == null) {
Control.SetTextSize(Android.Util.ComplexUnitType.Sp, 11.0f);
// right now the font size is hard coded. Id like to get the value from the custom control somehow.
// I tried Element but the property is not exposed via that
}
}
}
}