尝试向android添加渲染类,但无法找到方法。
[assembly:ExportRenderer(typeof(ExtendedSwitch),typeof(ExtendedSwitchRenderer))]
命名空间Common.Droid.Renderers { public class ExtendedSwitchRenderer:SwitchRenderer { public ExtendedSwitchRenderer(Context context) :base(context) {
}
protected override void OnElementChanged(ElementChangedEventArgs<Switch> e)
{
base.OnElementChanged(e);
if (Control != null && e.NewElement != null)
{
var element = (ExtendedSwitch) e.NewElement;
Control.TextOn = element.YesText ?? string.Empty;
Control.TextOff = element.NoText ?? string.Empty;
}
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
Control.SwitchMinWidth = 300;
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == ExtendedSwitch.YesTextProperty.PropertyName ||
e.PropertyName == ExtendedSwitch.NoTextProperty.PropertyName)
{
var element = (ExtendedSwitch) Element;
Control.TextOn = element.YesText ?? string.Empty;
Control.TextOff = element.NoText ?? string.Empty;
}
Control.SwitchMinWidth = 300;
}
}